From 5d9d0feb7fd6501c6f15578e5705ec17f7bf4efc Mon Sep 17 00:00:00 2001 From: "isaac.manuelraj" Date: Tue, 6 Nov 2018 17:50:50 +0530 Subject: Add new test cases. Added new test cases to the existing test cases. Issue-ID: SDC-1774 Change-Id: I7521aa2265153ef17b85e65b5c594fb660fb43c5 Signed-off-by: isaac.manuelraj --- .../components/impl/ResourceBusinessLogicTest.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'catalog-be') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index 13d0665e35..b6a7c98efa 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -22,6 +22,7 @@ package org.openecomp.sdc.be.components.impl; import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -29,6 +30,8 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.sdc.ElementOperationMock; import org.openecomp.sdc.be.auditing.impl.AuditingManager; +import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum; +import org.openecomp.sdc.be.model.operations.StorageException; import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils; import org.openecomp.sdc.be.components.csar.CsarBusinessLogic; import org.openecomp.sdc.be.components.csar.CsarInfo; @@ -174,6 +177,7 @@ public class ResourceBusinessLogicTest { Map emptyDataTypes = new HashMap<>(); private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class); CacheMangerOperation cacheManager = Mockito.mock(CacheMangerOperation.class); + List reslist; public ResourceBusinessLogicTest() { } @@ -215,6 +219,7 @@ public class ResourceBusinessLogicTest { Either eitherFalse = Either.left(true); when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherFalse); + Either eitherCountExist = Either.left(true); when(toscaOperationFacade.validateComponentNameExists("alreadyExists", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCountExist); @@ -272,6 +277,18 @@ public class ResourceBusinessLogicTest { when(toscaOperationFacade.getToscaFullElement(resourceCsar.getUniqueId())).thenReturn(oldResourceRes); responseManager = ResponseFormatManager.getInstance(); + reslist = new ArrayList(); + reslist.add(resourceResponse); + reslist.add(genericVF); + reslist.add(genericCR); + reslist.add(genericVFC); + reslist.add(genericPNF); + Either, StorageOperationStatus> returneval= Either.left(reslist); + when(toscaOperationFacade.getAllCertifiedResources(true, true)).thenReturn(returneval); + when(toscaOperationFacade.validateComponentNameUniqueness("Resource", ResourceTypeEnum.CR, ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(true)); + Either, StorageOperationStatus> returnevalexception= Either.right(StorageOperationStatus.BAD_REQUEST); + when(toscaOperationFacade.getAllCertifiedResources(false, false)).thenReturn(returnevalexception); + } private Resource createResourceObject(boolean afterCreate) { @@ -1863,4 +1880,24 @@ public class ResourceBusinessLogicTest { List listOfRoles = Stream.of(roles).collect(Collectors.toList()); } + + @Test + public void testgetAllCertifiedResources() throws Exception { + List list = bl.getAllCertifiedResources(true, HighestFilterEnum.HIGHEST_ONLY, "USER"); + Assert.assertEquals(reslist,list); + } + + @Test(expected = StorageException.class) + public void testgetAllCertifiedResources_exception() throws Exception { + List list = bl.getAllCertifiedResources(false, HighestFilterEnum.NON_HIGHEST_ONLY, "USER"); + Assert.assertEquals(reslist,list); + } + + @Test + public void testvalidateResourceNameExists() throws Exception { + Either, ResponseFormat> res = bl.validateResourceNameExists("Resource", ResourceTypeEnum.CR, "jh0003"); + Assert.assertEquals(true,res.isLeft()); + } + + } -- cgit 1.2.3-korg