summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test/java/org')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java37
1 files changed, 37 insertions, 0 deletions
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<String, DataTypeDefinition> emptyDataTypes = new HashMap<>();
private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
CacheMangerOperation cacheManager = Mockito.mock(CacheMangerOperation.class);
+ List<Resource> reslist;
public ResourceBusinessLogicTest() {
}
@@ -215,6 +219,7 @@ public class ResourceBusinessLogicTest {
Either<Boolean, StorageOperationStatus> eitherFalse = Either.left(true);
when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherFalse);
+
Either<Boolean, StorageOperationStatus> 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<Resource>();
+ reslist.add(resourceResponse);
+ reslist.add(genericVF);
+ reslist.add(genericCR);
+ reslist.add(genericVFC);
+ reslist.add(genericPNF);
+ Either<List<Resource>, 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<List<Resource>, 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<Role> listOfRoles = Stream.of(roles).collect(Collectors.toList());
}
+
+ @Test
+ public void testgetAllCertifiedResources() throws Exception {
+ List<Resource> list = bl.getAllCertifiedResources(true, HighestFilterEnum.HIGHEST_ONLY, "USER");
+ Assert.assertEquals(reslist,list);
+ }
+
+ @Test(expected = StorageException.class)
+ public void testgetAllCertifiedResources_exception() throws Exception {
+ List<Resource> list = bl.getAllCertifiedResources(false, HighestFilterEnum.NON_HIGHEST_ONLY, "USER");
+ Assert.assertEquals(reslist,list);
+ }
+
+ @Test
+ public void testvalidateResourceNameExists() throws Exception {
+ Either<Map<String, Boolean>, ResponseFormat> res = bl.validateResourceNameExists("Resource", ResourceTypeEnum.CR, "jh0003");
+ Assert.assertEquals(true,res.isLeft());
+ }
+
+
}