aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-04-22 19:00:33 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-03 10:56:36 +0000
commitf52d4072ccb95b3a69b8f17b87ee44513167029e (patch)
tree21bcde181de8afc1e6d139fa78ab8043b5240927 /catalog-be/src/test
parent789d5c745e2d1a6add6dbbc065296ce4254b3046 (diff)
Extract ArtifactOperationInfo from ArtifactsBusinessLogic
This commit only intends to extract the inner static class ArtifactOperationInfo from the ArtifactsBusinessLogic class. In addition, getters have been added to get the artifactOperationEnum field's state (this allowed to reduce some boilerplate). Change-Id: Ib79a75893ef11ba0d25e0578d7e95f60284589d0 Signed-off-by: Francis Toth <francis.toth@yoppworks.com> Issue-ID: SDC-2961
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java10
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java38
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java2
5 files changed, 26 insertions, 31 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
index 3fb25dfc77..e3e6924b7e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
@@ -112,12 +112,8 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{
@Mock
private UserBusinessLogic userBusinessLogic;
@Mock
- private ArtifactOperation artifactOperation;
- @Mock
public ComponentsUtils componentsUtils;
@Mock
- private UserAdminOperation userOperation;
- @Mock
private ArtifactCassandraDao artifactCassandraDao;
@Mock
public ToscaOperationFacade toscaOperationFacade;
@@ -148,13 +144,7 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{
@Before
public void initMocks() {
MockitoAnnotations.initMocks(this);
- Either<ArtifactDefinition, StorageOperationStatus> NotFoundResult = Either.right(StorageOperationStatus.NOT_FOUND);
-
- Either<Map<String, ArtifactDefinition>, StorageOperationStatus> NotFoundResult2 = Either.right(StorageOperationStatus.NOT_FOUND);
-
when(userBusinessLogic.getUser(eq("jh0003"), anyBoolean())).thenReturn(USER);
-
-
when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VFC);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
index cd7d9d556a..cfbc06234c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
@@ -78,7 +78,7 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.MockGenerator;
import org.openecomp.sdc.be.components.ArtifactsResolver;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
@@ -346,7 +346,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
.thenReturn(Either.left(new ArrayList()));
when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), new ArrayList<>(Arrays.asList("guid"))))
.thenReturn(StorageOperationStatus.OK);
- artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE,artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
+ artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE,
+ new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
"uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true);
assertThat(ci.getDeploymentArtifacts().get("HEAT").getTimeout()).isEqualTo(envArtifact.getTimeout());
assertThat(ci.getDeploymentArtifacts().get("HEAT_ENV").getTimeout()).isEqualTo(origEnvArtifact.getTimeout());
@@ -381,7 +382,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), new ArrayList<>(Arrays.asList("guid"))))
.thenReturn(StorageOperationStatus.OK);
try {
- artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
+ artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
"uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true);
} catch (ComponentException exp) {
assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.ARTIFACT_INVALID_TIMEOUT);
@@ -419,7 +420,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
when(toscaOperationFacade.generateCustomizationUUIDOnInstanceGroup(service.getUniqueId(), ci.getUniqueId(), new ArrayList<>(Arrays.asList("guid"))))
.thenReturn(StorageOperationStatus.OK);
try {
- artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
+ artifactBL.handleUpdate(ci.getUniqueId(), ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
"uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true);
} catch (ComponentException exp) {
assertThat(exp.getActionStatus()).isEqualTo(ActionStatus.ARTIFACT_INVALID_TIMEOUT);
@@ -452,7 +453,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
.thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service),eq(ci.getUniqueId()), any(List.class)))
.thenReturn(Either.left(new ArrayList()));
- artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE,artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
+ artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE,
+ new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
"uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true);
assertThat(ci.getDeploymentArtifacts().get("HEAT").getTimeout()).isEqualTo(origEnvArtifact.getTimeout());
}
@@ -477,7 +479,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
when(toscaOperationFacade.updateGroupInstancesOnComponent(eq(service),eq(ci.getUniqueId()), any(List.class)))
.thenReturn(Either.left(new ArrayList()));
assertThatThrownBy(() -> {
- artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE,artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
+ artifactBL.handleUpdate(ci.getUniqueId(),ComponentTypeEnum.RESOURCE_INSTANCE,
+ new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
"uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, service, true);
}).isInstanceOf(ComponentException.class);
}
@@ -488,7 +491,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
envArtifact.setArtifactType("invalid");
try {
- artifactBL.handleUpdate("uid", ComponentTypeEnum.RESOURCE_INSTANCE, artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
+ artifactBL.handleUpdate("uid", ComponentTypeEnum.RESOURCE_INSTANCE, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE),
"uid2", envArtifact, null, null, null, null, null, AuditingActionEnum.ARTIFACT_METADATA_UPDATE, user, null, true);
fail();
} catch(ComponentException exp) {
@@ -952,7 +955,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
String componentId = "";
ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE;
ArtifactsBusinessLogic arb = getTestSubject();
- ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ ArtifactOperationInfo operation = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
String artifactId = "";
ArtifactDefinition artifactInfo = buildArtifactPayload();
AuditingActionEnum auditingAction = AuditingActionEnum.ADD_CATEGORY;
@@ -1048,7 +1051,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
public void testIgnoreUnupdateableFieldsInUpdate() throws Exception {
ArtifactsBusinessLogic testSubject;
ArtifactsBusinessLogic arb = getTestSubject();
- ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ ArtifactOperationInfo operation = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
ArtifactDefinition artifactInfo = buildArtifactPayload();
ArtifactDefinition currentArtifactInfo = null;
@@ -1065,7 +1068,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE;
String parentId = "";
ArtifactsBusinessLogic arb = getTestSubject();
- ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ ArtifactOperationInfo operation = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
String artifactId = "";
Either<ArtifactDefinition, ResponseFormat> result;
@@ -1579,7 +1582,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
String artifactId = "";
ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE;
ArtifactsBusinessLogic arb = getTestSubject();
- ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ ArtifactOperationInfo operation = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
Either<Boolean, ResponseFormat> result;
// default test
@@ -1594,7 +1597,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
public void testDetectAuditingType() throws Exception {
ArtifactsBusinessLogic testSubject;
ArtifactsBusinessLogic arb = getTestSubject();
- ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ ArtifactOperationInfo operation = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
String origMd5 = "";
AuditingActionEnum result;
@@ -1609,7 +1612,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
public void testDetectNoAuditingType() throws Exception {
ArtifactsBusinessLogic testSubject;
ArtifactsBusinessLogic arb = getTestSubject();
- ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.LINK);
+ ArtifactOperationInfo operation = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.LINK);
String origMd5 = "";
AuditingActionEnum result;
@@ -1921,7 +1924,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
List<ArtifactDefinition> vfcsNewCreatedArtifacts = new ArrayList<>();
ArtifactsBusinessLogic arb = getTestSubject();
- ArtifactOperationInfo operation = arb.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ ArtifactOperationInfo operation = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
boolean shouldLock = false;
boolean inTransaction = false;
List<ArtifactDefinition> result;
@@ -2035,7 +2038,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
service.setLastUpdaterUserId(user.getUserId());
final ArtifactOperationInfo operationInfo =
- artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
final String componentId = "componentId";
final ComponentInstance componentInstance = new ComponentInstance();
@@ -2089,7 +2092,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
service.setLastUpdaterUserId(user.getUserId());
final ArtifactOperationInfo operationInfo =
- artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
+ new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE);
final String componentId = "componentId";
final ComponentInstance componentInstance = new ComponentInstance();
@@ -2103,6 +2106,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject();
artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
+
final Object result = Deencapsulation
.invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId,
user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service);
@@ -2115,7 +2119,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
public void testHandleArtifactRequest() {
String componentId = "componentId";
- ArtifactOperationInfo operationInfo = artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE);
+ ArtifactOperationInfo operationInfo = new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE);
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
artifactDefinition.setArtifactName("other");
artifactDefinition.setUniqueId("artifactId");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java
index 160f595e95..66c535e0ce 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java
@@ -28,7 +28,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -135,7 +135,7 @@ public class ComponentInstanceArtifactsMergeTest {
User user = new User();
when(artifactsBusinessLogicMock.updateResourceInstanceArtifactNoContent("mock", originComponent, user,
- new HashMap<>(), artifactsBusinessLogicMock.new ArtifactOperationInfo(false, false,
+ new HashMap<>(), new ArtifactOperationInfo(false, false,
ArtifactsBusinessLogic.ArtifactOperationEnum.LINK), currentDeploymentArtifacts.get("artifactOne"))).thenReturn(left);
when(artifactsBusinessLogicMock.updateResourceInstanceArtifactNoContent(Mockito.anyString(), Mockito.any(Component.class), Mockito.any(User.class),
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java
index 5f70d9d01f..a23508f797 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMergeTest.java
@@ -28,6 +28,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.merge.heat.HeatEnvArtifactsMergeBusinessLogic;
import org.openecomp.sdc.be.components.utils.ArtifactBuilder;
import org.openecomp.sdc.be.components.utils.ComponentInstanceBuilder;
@@ -90,7 +91,7 @@ public class ComponentInstanceHeatEnvMergeTest {
for (ArtifactDefinition mergedArtifact : mergedArtifacts) {
Map<String, Object> json = new HashMap<>();
when(artifactsBusinessLogicMock.buildJsonForUpdateArtifact(mergedArtifact, ArtifactGroupTypeEnum.DEPLOYMENT, null)).thenReturn(json);
- ArtifactsBusinessLogic.ArtifactOperationInfo artifactUpdateOperation = artifactsBusinessLogicMock.new ArtifactOperationInfo(false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE);
+ ArtifactOperationInfo artifactUpdateOperation = new ArtifactOperationInfo(false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE);
when(artifactsBusinessLogicMock.updateResourceInstanceArtifactNoContent(Mockito.eq(instanceId), Mockito.eq(resource),
Mockito.eq(USER), Mockito.eq(json),
Mockito.refEq(artifactUpdateOperation),
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
index c7dced79c5..092dd1d2b5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
@@ -58,7 +58,7 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.BeConfDependentTest;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;