diff options
Diffstat (limited to 'catalog-be/src/test/java')
9 files changed, 28 insertions, 26 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java index 5d05e65886..117ef9cc5a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java @@ -282,7 +282,7 @@ public class ElementOperationMock implements IElementOperation { } @Override - public List<BaseType> getBaseTypes(String categoryName) { + public List<BaseType> getBaseTypes(String categoryName, String modelName) { // TODO Auto-generated method stub return null; } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index 00e0681c8d..1609299e66 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -110,7 +110,7 @@ public class ResourceImportManagerTest { public static void beforeClass() { importManager = new ResourceImportManager(componentsUtils, capabilityTypeOperation, interfaceDefinitionHandler); importManager.setAuditingManager(auditingManager); - when(toscaOperationFacade.getLatestByToscaResourceName(Mockito.anyString())).thenReturn(Either.left(null)); + when(toscaOperationFacade.getLatestByToscaResourceName(Mockito.anyString(), Mockito.any())).thenReturn(Either.left(null)); when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(Mockito.anyString(), Mockito.any())).thenReturn(Either.left(null)); importManager.setResponseFormatManager(responseFormatManager); importManager.setResourceBusinessLogic(resourceBusinessLogic); @@ -130,7 +130,7 @@ public class ResourceImportManagerTest { Mockito.reset(auditingManager, responseFormatManager, resourceBusinessLogic, userAdmin); Either<Component, StorageOperationStatus> notFound = Either.right(StorageOperationStatus.NOT_FOUND); when(toscaOperationFacade.getComponentByNameAndVendorRelease(any(ComponentTypeEnum.class), anyString(), anyString(), - any(JsonParseFlagEnum.class))).thenReturn(notFound); + any(JsonParseFlagEnum.class), any())).thenReturn(notFound); } @Test @@ -308,7 +308,7 @@ public class ResourceImportManagerTest { setResourceBusinessLogicMock(); final Either<Component, StorageOperationStatus> foundResourceEither = Either.left(Mockito.mock(Resource.class)); when(toscaOperationFacade.getComponentByNameAndVendorRelease(any(ComponentTypeEnum.class), anyString(), anyString(), - any(JsonParseFlagEnum.class))).thenReturn(foundResourceEither); + any(JsonParseFlagEnum.class), any())).thenReturn(foundResourceEither); when(toscaOperationFacade.isNodeAssociatedToModel(eq(null), any(Resource.class))).thenReturn(true); String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-blockStorage.yml"); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java index a2996c531d..3029bf7bc1 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java @@ -33,6 +33,7 @@ import static org.junit.jupiter.api.DynamicTest.dynamicTest; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -1851,7 +1852,7 @@ class ComponentInstanceBusinessLogicTest { .thenReturn(Either.left(service)); when(toscaOperationFacade.getToscaFullElement(eq(ORIGIN_COMPONENT_ID))) .thenReturn(Either.left(originService)); - when(toscaOperationFacade.getLatestByToscaResourceName(eq(originService.getDerivedFromGenericType()))) + when(toscaOperationFacade.getLatestByToscaResourceName(eq(originService.getDerivedFromGenericType()), isNull())) .thenReturn(Either.left(serviceBaseComponent)); when(toscaOperationFacade.getToscaElement(eq(ORIGIN_COMPONENT_ID), any(ComponentParametersView.class))) .thenReturn(Either.left(originService)); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java index 36eee96848..f52ae209db 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java @@ -312,16 +312,17 @@ public class ElementBusinessLogicTest extends BaseBusinessLogicMock { List<BaseType> baseTypes = new ArrayList<>(); baseTypes.add(new BaseType("org.openecomp.type")); String categoryName = "CAT01"; + String modelName = "MODEL01"; when(userValidations.validateUserExistsActionStatus(eq(user.getUserId()))).thenReturn(ActionStatus.OK); - when(elementDao.getBaseTypes(categoryName)).thenReturn(baseTypes); - Assert.assertTrue(elementBusinessLogic.getBaseTypes(categoryName, user.getUserId()) + when(elementDao.getBaseTypes(categoryName, modelName)).thenReturn(baseTypes); + Assert.assertTrue(elementBusinessLogic.getBaseTypes(categoryName, user.getUserId(), modelName) .isLeft()); } @Test public void testGetBaseTypes_givenUserValidationFails_thenReturnsException() { when(userValidations.validateUserExistsActionStatus(eq(user.getUserId()))).thenReturn(ActionStatus.RESTRICTED_OPERATION); - Assert.assertTrue(elementBusinessLogic.getBaseTypes("CAT01", user.getUserId()).isRight()); + Assert.assertTrue(elementBusinessLogic.getBaseTypes("CAT01", user.getUserId(), null).isRight()); } }
\ No newline at end of file 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 a2893af2ba..cfbd63363a 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 @@ -1460,7 +1460,7 @@ public class ResourceBusinessLogicTest { YamlTemplateParsingHandler yamlTemplateParser = new YamlTemplateParsingHandler(mockJanusGraphDao, null, Mockito.mock(AnnotationBusinessLogic.class), null); final ParsedToscaYamlInfo parsedToscaYamlInfo = yamlTemplateParser.parseResourceInfoFromYAML("Definitions/my_vnf.yml", resourceYml, Collections.EMPTY_MAP, Collections.EMPTY_MAP, "myVnf", resourceResponse); - when(toscaOperationFacade.getLatestByToscaResourceName(anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); + when(toscaOperationFacade.getLatestByToscaResourceName(anyString(), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); Resource vduCp = new Resource(); vduCp.setToscaResourceName("tosca.nodes.nfv.VduCp"); vduCp.setState(LifecycleStateEnum.CERTIFIED); @@ -1673,7 +1673,7 @@ public class ResourceBusinessLogicTest { when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate); Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(true); - when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString())) + when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), anyString())) .thenReturn(isToscaNameExtending); Either<Map<String, PropertyDefinition>, StorageOperationStatus> findPropertiesOfNode = Either @@ -1703,7 +1703,7 @@ public class ResourceBusinessLogicTest { when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate); Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(false); - when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString())) + when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), anyString())) .thenReturn(isToscaNameExtending); resource.setVersion("1.0"); @@ -1740,7 +1740,7 @@ public class ResourceBusinessLogicTest { assertThat(createdResource).isNotNull(); Either<Resource, StorageOperationStatus> getLatestResult = Either.left(createdResource); Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(createdResource); - when(toscaOperationFacade.getLatestByToscaResourceName(resourceExist.getToscaResourceName())) + when(toscaOperationFacade.getLatestByToscaResourceName(resourceExist.getToscaResourceName(), null)) .thenReturn(getCompLatestResult); when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(resourceExist.getToscaResourceName(), null)) .thenReturn(getCompLatestResult); @@ -1851,9 +1851,9 @@ public class ResourceBusinessLogicTest { .getRight(); when(toscaOperationFacade.getLatestByName(resourceToUpdate.getName(), null)) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); - when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName())) + when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName(), null)) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); - when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName)) + when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName, null)) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(resourceToUpdate.getToscaResourceName(), null)) @@ -1889,11 +1889,11 @@ public class ResourceBusinessLogicTest { .getRight(); when(toscaOperationFacade.getLatestByName(resourceToUpdate.getName(), null)) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); - when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName())) + when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName(), null)) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(resourceToUpdate.getToscaResourceName(), null)) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); - when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName)) + when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName, null)) .thenReturn(Either.left(resourceResponse)); when(toscaOperationFacade.overrideComponent(any(Resource.class), any(Resource.class))) .thenReturn(Either.left(resourceResponse)); @@ -2283,7 +2283,7 @@ public class ResourceBusinessLogicTest { private Resource createRoot() { rootType = setupGenericTypeMock(GENERIC_ROOT_NAME); - when(toscaOperationFacade.getLatestByToscaResourceName(GENERIC_ROOT_NAME)) + when(toscaOperationFacade.getLatestByToscaResourceName(GENERIC_ROOT_NAME, null)) .thenReturn(Either.left(rootType)); return rootType; } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java index a3232f61ce..ccc7139fa6 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java @@ -203,7 +203,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet final Service service = createServiceObject(false); Resource resource = new Resource(); Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(resource); - when(toscaOperationFacade.getLatestByToscaResourceName(anyString())) + when(toscaOperationFacade.getLatestByToscaResourceName(anyString(), any())) .thenReturn(getCompLatestResult); final CsarInfo csarInfo = getCsarInfo(); @@ -229,7 +229,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet final Service service = createServiceObject(false); Resource resource = new Resource(); Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(resource); - when(toscaOperationFacade.getLatestByToscaResourceName(anyString())) + when(toscaOperationFacade.getLatestByToscaResourceName(anyString(), any())) .thenReturn(getCompLatestResult); Assertions.assertNotNull(extractedVfcsArtifacts); testSubject.findAddNodeTypeArtifactsToHandle(getCsarInfo(), nodeTypesArtifactsToHandle, service, @@ -1205,7 +1205,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet updatedDerivedFromList.add("23344567778"); updateInfoResource.setDerivedFrom(updatedDerivedFromList); - when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString())) + when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), any())) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); Assertions.assertNotNull( @@ -1218,7 +1218,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet Resource currentResource = createParseResourceObject(true); Resource updateInfoResource = createParseResourceObject(true); - when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString())) + when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), any())) .thenReturn(Either.left(false)); Assertions.assertNotNull( diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java index 3774332b23..3fbd84f6a4 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java @@ -55,12 +55,12 @@ public class ForwardingPathToscaOperationFacade extends ToscaOperationFacade { } @Override - public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName) { + public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName, String model) { if(toscaResourceName.equals(ForwardingPathUtils.FORWARDING_PATH_NODE_NAME) || toscaResourceName.equals(ForwardingPathUtils.FORWARDER_CAPABILITY)){ Resource component = new Resource(); component.setToscaResourceName(GENERIC_SERVICE_NAME); return Either.left((T)component); } - return super.getLatestByToscaResourceName(toscaResourceName); + return super.getLatestByToscaResourceName(toscaResourceName, model); } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java index 4d2c3621d9..c1837846f6 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java @@ -1110,7 +1110,7 @@ class ElementServletTest extends JerseyTest { void getBaseTypesTest() { String path = "/v1/category/services/CAT1/baseTypes"; Either<List<BaseType>, ActionStatus> baseTypesEither = Either.left(new ArrayList<>()); - when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId())) + when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId(), null)) .thenReturn(baseTypesEither); Response response = target() @@ -1128,7 +1128,7 @@ class ElementServletTest extends JerseyTest { String path = "/v1/category/services/CAT1/baseTypes"; Either<List<BaseType>, ActionStatus> baseTypesEither = Either.right(ActionStatus.NO_CONTENT); - when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId())) + when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId(), null)) .thenReturn(baseTypesEither); Response response = target() diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java index 38c72922fd..325a003133 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java @@ -529,7 +529,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { component.setDerivedFromGenericType("org.typeA"); component.setDerivedFromGenericVersion("1.0"); - when(toscaOperationFacade.getByToscaResourceNameAndVersion("org.typeA", "1.0")).thenReturn(Either.left(baseType)); + when(toscaOperationFacade.getByToscaResourceNameAndVersion("org.typeA", "1.0", null)).thenReturn(Either.left(baseType)); // default test result = Deencapsulation.invoke(testSubject, "fillImports", component, toscaTemplate); |