diff options
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java index 552d5cad64..09f8848c09 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathBusinessLogicTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.Sets; import fj.data.Either; import org.junit.Test; import org.junit.runner.RunWith; +import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum; @@ -35,34 +36,34 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/paths/path-context.xml") public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { - @Test + @Test(expected = ComponentException.class) public void shouldFailToUpdateForwardingPathSincePathDoesNotExist() { Service service = initForwardPath(); - Either<Service, ResponseFormat> serviceResponseFormatEither = bl.updateForwardingPath(FORWARDING_PATH_ID, service, user, true); - assertTrue(serviceResponseFormatEither.isRight()); + bl.updateForwardingPath(FORWARDING_PATH_ID, service, user, true); } - @Test + @Test(expected = ComponentException.class) public void shouldFailToDeleteForwardingPathSincePathDoesNotExist() { - Service service = initForwardPath(); - Either<Set<String>, ResponseFormat> serviceResponseFormatEither = bl.deleteForwardingPaths("delete_forward_test", Sets.newHashSet(FORWARDING_PATH_ID), user, true); - assertTrue(serviceResponseFormatEither.isRight()); + initForwardPath(); + bl.deleteForwardingPaths("delete_forward_test", Sets.newHashSet(FORWARDING_PATH_ID), user, true); } - @Test + @Test public void shouldSucceedCreateAndDeleteForwardingPath() { Service createdService = createService(); Service service = initForwardPath(); assertNotNull(service); - Either<Service, ResponseFormat> serviceResponseFormatEither = bl.createForwardingPath(createdService.getUniqueId(), service, user, true); - assertTrue(serviceResponseFormatEither.isLeft()); - Map<String, ForwardingPathDataDefinition> forwardingPathsMap = serviceResponseFormatEither.left().value().getForwardingPaths(); + Service serviceResponseFormatEither = bl.createForwardingPath(createdService.getUniqueId(), service, user, true); + assertTrue(serviceResponseFormatEither != null); + Map<String, ForwardingPathDataDefinition> forwardingPathsMap = serviceResponseFormatEither.getForwardingPaths(); Set<String> pathIds = forwardingPathsMap.keySet(); assertEquals(1, pathIds.size()); String toscaResourceName = forwardingPathsMap.values().iterator().next().getToscaResourceName(); @@ -87,7 +88,7 @@ public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { service.getForwardingPaths().clear(); service.getForwardingPaths().put(forwardingPathDataDefinitionUpdate.getUniqueId(), forwardingPathDataDefinitionUpdate); serviceResponseFormatEither = bl.updateForwardingPath(createdService.getUniqueId(), service, user, true); - assertTrue(serviceResponseFormatEither.isLeft()); + assertTrue(serviceResponseFormatEither != null); // make sure changes were applied uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, Lists.newArrayList(ComponentFieldsEnum.FORWARDING_PATHS.getValue())); @@ -98,10 +99,10 @@ public class ForwardingPathBusinessLogicTest extends BaseForwardingPathTest { assertEquals(newProtocol, updatedData.getProtocol()); assertTrue(updatedData.getPathElements().isEmpty()); - Service createdData = serviceResponseFormatEither.left().value(); + Service createdData = serviceResponseFormatEither; Set<String> paths = createdData.getForwardingPaths().keySet(); - Either<Set<String>, ResponseFormat> setResponseFormatEither = bl.deleteForwardingPaths(createdService.getUniqueId(), paths, user, true); - assertTrue(setResponseFormatEither.isLeft()); + Set<String> setResponseFormatEither = bl.deleteForwardingPaths(createdService.getUniqueId(), paths, user, true); + assertTrue(setResponseFormatEither != null); // nothing to return now uiResaponse = bl.getComponentDataFilteredByParams(createdService.getUniqueId(), user, Lists.newArrayList(ComponentFieldsEnum.COMPONENT_INSTANCES.getValue(),ComponentFieldsEnum.FORWARDING_PATHS.getValue())); |