Fix error in userId handling
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / impl / ArtifactsBusinessLogicTest.java
index c13a465..36d22bc 100644 (file)
@@ -728,11 +728,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
         DAOArtifactData.setDataAsArray(payload);
         Either<DAOArtifactData, CassandraOperationStatus> artifactfromESres = Either.left(DAOArtifactData);
         when(artifactCassandraDao.getArtifact(esArtifactId)).thenReturn(artifactfromESres);
-        List<org.openecomp.sdc.be.model.Component> serviceList = new ArrayList<>();
-        serviceList.add(service);
-        Either<List<org.openecomp.sdc.be.model.Component>, StorageOperationStatus> getServiceRes = Either
-            .left(serviceList);
-        when(toscaOperationFacade.getBySystemName(ComponentTypeEnum.SERVICE, serviceName)).thenReturn(getServiceRes);
+        when(toscaOperationFacade.getBySystemNameAndVersion(ComponentTypeEnum.SERVICE, serviceName, serviceVersion)).thenReturn(Either.left(service));
         byte[] downloadServiceArtifactByNamesRes = artifactBL
             .downloadServiceArtifactByNames(serviceName, serviceVersion, artifactName);
         assertThat(downloadServiceArtifactByNamesRes != null
@@ -2143,6 +2139,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
 
         when(userValidations.validateUserExists(Mockito.eq("userId")))
             .thenReturn(user);
+        when(userValidations.isSameUser(Mockito.eq("userId"), Mockito.eq("userId")))
+            .thenReturn(true);
         when(toscaOperationFacade.getToscaFullElement(any()))
             .thenReturn(Either.left(resource));
         when(artifactToscaOperation.getArtifactById(any(), any(), any(), any()))
@@ -2263,6 +2261,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
 
         when(userValidations.validateUserExists(eq(user.getUserId())))
             .thenReturn(user);
+        when(userValidations.isSameUser(Mockito.eq("userId"), Mockito.eq("userId")))
+            .thenReturn(true);
         when(toscaOperationFacade.getToscaFullElement(eq(componentId)))
             .thenReturn(Either.left(resource));
         when(artifactToscaOperation.getArtifactById(anyString(), anyString(), any(ComponentTypeEnum.class), anyString()))
@@ -2428,19 +2428,15 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
         esArtifactData.setDataAsArray("test".getBytes());
 
         artifactDefinition.setArtifactName(artifactName);
-        List<Service> serviceList = new ArrayList<>();
         Map<String, ArtifactDefinition> artifacts = new HashMap<>();
         artifacts.put(artifactName, artifactDefinition);
-
-        serviceList.add(service);
         resource.setDeploymentArtifacts(artifacts);
 
         when(toscaOperationFacade.getComponentByNameAndVersion(eq(ComponentTypeEnum.RESOURCE), eq(resourceName), eq(version),
             eq(JsonParseFlagEnum.ParseMetadata)))
             .thenReturn(Either.left(resource));
-        doReturn(Either.left(serviceList)).when(toscaOperationFacade).getBySystemName(eq(ComponentTypeEnum.SERVICE), eq(serviceName));
-        when(artifactCassandraDao.getArtifact(any()))
-            .thenReturn(Either.left(esArtifactData));
+        doReturn(Either.left(service)).when(toscaOperationFacade).getBySystemNameAndVersion(ComponentTypeEnum.SERVICE, serviceName, version);
+        when(artifactCassandraDao.getArtifact(any())).thenReturn(Either.left(esArtifactData));
 
         byte[] result = artifactBL.downloadRsrcArtifactByNames(serviceName, version, resourceName, version, artifactName);
         Assert.assertEquals(esArtifactData.getDataAsArray(), result);
@@ -2455,4 +2451,4 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
         artifactsBusinessLogic.setComponentsUtils(componentsUtils);
         return artifactsBusinessLogic;
     }
-}
\ No newline at end of file
+}