+ @Test
+ @Parameters({"200", "404"})
+ public void shouldremovePublisherSubscriberViewerPermissions(int aafServiceReturnedCode) {
+ aafService.givenReturnCode(aafServiceReturnedCode);
+
+ aafTopicSetupService.aafTopicCleanup(givenTopic(TOPIC_FQTN));
+
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + TOPIC_FQTN, "pub"));
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + TOPIC_FQTN, "sub"));
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + TOPIC_FQTN, "view"));
+ }
+
+ @Test
+ @Parameters({"200", "404"})
+ public void shouldRemoveNamespace(int aafServiceReturnedCode) {
+ aafService.givenReturnCode(aafServiceReturnedCode);
+ Topic topic = givenTopic(TOPIC_FQTN);
+
+ aafTopicSetupService.aafTopicCleanup(topic);
+
+ AafNamespace namespace = new AafNamespace(TOPIC_FQTN, IDENTITY);
+ aafService.shouldRemoveNamespace(namespace);
+ }
+
+ @Test
+ public void shouldRemoveOnlyPermissionsWhenCreateTopicRolesIsFalse() {
+ aafTopicSetupService = new AafTopicSetupService(aafService, dmaapService, false);
+
+ aafTopicSetupService.aafTopicCleanup(givenTopic(TOPIC_FQTN));
+
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + TOPIC_FQTN, "pub"));
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + TOPIC_FQTN, "sub"));
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + TOPIC_FQTN, "view"));
+ aafService.shouldNotRemoveNamespace();
+ }
+
+ @Test
+ public void shouldRemoveOnlyPermissionsWhenTopicFqtnDoesntStartWithNsRoot() {
+
+ String topicFqtn = "sample_topic";
+ aafTopicSetupService.aafTopicCleanup(givenTopic(topicFqtn));
+
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + topicFqtn, "pub"));
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + topicFqtn, "sub"));
+ aafService.shouldRemovePerm(new DmaapPerm(TOPIC_PERM, ":topic." + topicFqtn, "view"));
+ aafService.shouldNotRemoveNamespace();
+ }
+
+ @Test
+ public void shouldHandleExceptionWhenPermissionRemovalWasFailed() {
+ aafService.givenRemovePermStatus(INTERNAL_SERVER_ERROR);
+
+ ApiError apiError = aafTopicSetupService.aafTopicCleanup(givenTopic(TOPIC_FQTN));
+
+ assertErrorStatus(apiError, INTERNAL_SERVER_ERROR);
+ }
+
+ @Test
+ public void shouldHandleExceptionWhenNamespaceRemovalWasFailed() {
+ aafService.givenRemoveNamespaceStatus(INTERNAL_SERVER_ERROR);
+
+ ApiError apiError = aafTopicSetupService.aafTopicCleanup(givenTopic(TOPIC_FQTN));
+
+ assertErrorStatus(apiError, INTERNAL_SERVER_ERROR);
+ }
+