diff options
author | az2497 <avi.ziv@amdocs.com> | 2017-08-10 17:49:40 +0300 |
---|---|---|
committer | az2497 <avi.ziv@amdocs.com> | 2017-08-10 18:47:32 +0300 |
commit | 644017cb3edd5b7a077a634ffd5daf2fee6bc088 (patch) | |
tree | d371219cede1734d6909568325345ef196be677b /openecomp-be/backend/openecomp-sdc-action-manager/src | |
parent | 7f7925e39cf2f428061d161bc4ffe67cad80c76e (diff) |
[SDC] OnBoard with enabled tests and features
Change-Id: I4c1bbf6e1c854cf97a3561c736f83da44b58b7c0
Signed-off-by: az2497 <avi.ziv@amdocs.com>
[SDC] OnBoard with enabled tests and features.
Change-Id: Icd52f039aee4dd393a1404d530bb9fdd0b20e604
Signed-off-by: az2497 <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-action-manager/src')
2 files changed, 52 insertions, 4 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java index 4f58957c2d..36493e2b14 100644 --- a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java @@ -68,6 +68,7 @@ import static org.openecomp.sdc.action.util.ActionUtil.actionLogPreProcessor; import static org.openecomp.sdc.action.util.ActionUtil.getCurrentTimeStampUtc; import static org.openecomp.sdc.versioning.dao.types.Version.VERSION_STRING_VIOLATION_MSG; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.openecomp.sdc.action.types.*; import org.openecomp.sdc.logging.api.Logger; @@ -142,7 +143,7 @@ public class ActionManagerImpl implements ActionManager { @Override public List<Action> getActionsByActionInvariantUuId(String invariantId) throws ActionException { - List<Action> actions = null; + List<Action> actions; log.debug(" entering getActionsByActionInvariantUuId with invariantID = " + invariantId); actions = actionDao @@ -291,6 +292,7 @@ public class ActionManagerImpl implements ActionManager { String errorDesc = String .format(ACTION_ENTITY_UNIQUE_VALUE_MSG, ActionConstants.UniqueValues.ACTION_NAME, action.getName()); + log.error(errorDesc, exception); actionLogPostProcessor(StatusCode.ERROR, ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc, false); throw new ActionException(ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc); } finally { @@ -470,7 +472,7 @@ public class ActionManagerImpl implements ActionManager { List<ActionArtifact> currentVersionArtifacts = action.getArtifacts(); //Delete the artifacts from action_artifact table (if any) - if (currentVersionArtifacts != null && currentVersionArtifacts.size() > 0) { + if (CollectionUtils.isNotEmpty(currentVersionArtifacts) && currentVersionArtifacts.size() > 0) { for (ActionArtifact artifact : currentVersionArtifacts) { ActionArtifactEntity artifactDeleteEntity = new ActionArtifactEntity(artifact.getArtifactUuId(), diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java index ec8f0c439c..a8f7b692ab 100644 --- a/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java +++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java @@ -57,6 +57,8 @@ import org.openecomp.sdc.versioning.dao.types.Version; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import java.io.File; import java.io.FileInputStream; @@ -71,6 +73,9 @@ import java.util.UUID; @SuppressWarnings("Duplicates") public class ActionTest { + + /* + Logger logger = LoggerFactory.getLogger(ActionTest.class); private static final Version VERSION01 = new Version(0, 1); private static final String USER1 = "actionTestUser1"; private static final String USER2 = "actionTestUser2"; @@ -325,6 +330,7 @@ public class ActionTest { actionManager.createAction(createAction(ACTION_1), USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_ENTITY_UNIQUE_VALUE_ERROR); } } @@ -377,6 +383,7 @@ public class ActionTest { actionManager.updateAction(action, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert .assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE_NAME); } @@ -395,6 +402,7 @@ public class ActionTest { actionManager.updateAction(action, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_UPDATE_INVALID_VERSION); } } @@ -413,6 +421,7 @@ public class ActionTest { actionManager.updateAction(updatedAction, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE); } } @@ -435,7 +444,7 @@ public class ActionTest { boolean result = message.contains("No enum constant"); Assert.assertEquals(true, result); } - }*/ + } @Test(groups = "updateTestGroup", dependsOnMethods = {"updateTest"}) public void testUpdateInvariantId_negative() { @@ -450,6 +459,7 @@ public class ActionTest { actionManager.updateAction(action, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE); } } @@ -470,6 +480,7 @@ public class ActionTest { actionManager.updateAction(action, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE); } } @@ -487,8 +498,10 @@ public class ActionTest { actionManager.updateAction(action, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE); } catch (IllegalArgumentException ie) { + logger.error(ie.getMessage()); String message = ie.getMessage(); boolean result = message.contains("No enum constant"); Assert.assertEquals(true, result); @@ -508,6 +521,7 @@ public class ActionTest { actionManager.updateAction(action, USER2); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER); } @@ -518,6 +532,7 @@ public class ActionTest { try { actionManager.checkout(action1Id, USER1); } catch (ActionException wae) { + logger.error(wae.getMessage()); Assert .assertEquals(wae.getErrorCode(), ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY); Assert.assertEquals(wae.getDescription(), @@ -531,6 +546,7 @@ public class ActionTest { try { actionManager.checkout(action1Id, "invlaiduser"); } catch (ActionException wae) { + logger.error(wae.getMessage()); Assert.assertEquals(wae.getErrorCode(), ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER); Assert.assertEquals(wae.getDescription(), @@ -560,6 +576,7 @@ public class ActionTest { actionManager.updateAction(existingActionEntity.toDto(), USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_UPDATE_ON_UNLOCKED_ENTITY); } } @@ -576,6 +593,7 @@ public class ActionTest { try { actionManager.checkin(action1Id, "invaliduser"); } catch (ActionException wae) { + logger.error(wae.getMessage()); Assert .assertEquals(wae.getErrorCode(), ActionErrorConstants.ACTION_CHECKIN_ON_UNLOCKED_ENTITY); Assert.assertEquals(wae.getDescription(), @@ -598,6 +616,7 @@ public class ActionTest { try { actionManager.checkin(action1Id, "invaliduser"); } catch (ActionException wae) { + logger.error(wae.getMessage()); Assert.assertEquals(wae.getErrorCode(), ActionErrorConstants.ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER); Assert.assertEquals(wae.getDescription(), @@ -611,6 +630,7 @@ public class ActionTest { try { actionManager.submit(action1Id, USER1); } catch (ActionException wae) { + logger.error(wae.getMessage()); Assert.assertEquals(wae.getErrorCode(), ActionErrorConstants.ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED); Assert.assertEquals(wae.getDescription(), "Versionable entity Action with id " + action1Id + @@ -655,6 +675,7 @@ public class ActionTest { Action action = actionManager.getActionsByActionUuId(""); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE); } } @@ -780,6 +801,7 @@ public class ActionTest { actionManager.deleteAction(deleteActionInvariantId, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ACTION_DELETE_ON_LOCKED_ENTITY_CODE); Assert.assertEquals(exception.getDescription(), String.format( "Can not delete versionable entity Action with id %s since it is checked out by other user: %s", @@ -794,6 +816,7 @@ public class ActionTest { actionManager.checkin(deleteActionInvariantId, USER1); actionManager.deleteAction(deleteActionInvariantId, USER1); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.fail("Delete action test failed with exception : " + exception.getDescription()); } } @@ -805,6 +828,7 @@ public class ActionTest { actionManager.checkout(deleteActionInvariantId, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ACTION_ENTITY_NOT_EXIST_CODE); Assert.assertEquals(exception.getDescription(), ACTION_ENTITY_NOT_EXIST); } @@ -812,6 +836,7 @@ public class ActionTest { actionManager.checkin(deleteActionInvariantId, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ACTION_ENTITY_NOT_EXIST_CODE); Assert.assertEquals(exception.getDescription(), ACTION_ENTITY_NOT_EXIST); } @@ -819,6 +844,7 @@ public class ActionTest { actionManager.submit(deleteActionInvariantId, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ACTION_ENTITY_NOT_EXIST_CODE); Assert.assertEquals(exception.getDescription(), ACTION_ENTITY_NOT_EXIST); } @@ -826,6 +852,7 @@ public class ActionTest { actionManager.undoCheckout(deleteActionInvariantId, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ACTION_ENTITY_NOT_EXIST_CODE); Assert.assertEquals(exception.getDescription(), ACTION_ENTITY_NOT_EXIST); } @@ -833,6 +860,7 @@ public class ActionTest { actionManager.deleteAction(deleteActionInvariantId, USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ACTION_ENTITY_NOT_EXIST_CODE); Assert.assertEquals(exception.getDescription(), ACTION_ENTITY_NOT_EXIST); } @@ -844,6 +872,7 @@ public class ActionTest { actionManager.createAction(createAction(ACTION_TEST_DELETE), USER1); Assert.fail(); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ACTION_ENTITY_UNIQUE_VALUE_ERROR); Assert.assertEquals(exception.getDescription(), String .format(ACTION_ENTITY_UNIQUE_VALUE_MSG, ActionConstants.UniqueValues.ACTION_NAME, @@ -889,7 +918,7 @@ public class ActionTest { /*** * ACTION ARTIFACT OPERATION TEST CASES ***/ - +/* @Test public void testUploadArtifact() { actionArtifact = new ActionArtifact(); @@ -908,6 +937,7 @@ public class ActionTest { actionArtifact.setArtifactDescription("Test Artifact Description"); actionArtifact.setArtifactProtection(ActionArtifactProtection.readWrite.name()); } catch (IOException exception) { + logger.error(exception.getMessage()); exception.printStackTrace(); } @@ -942,6 +972,7 @@ public class ActionTest { try { actionManager.uploadArtifact(testArtifact, "INVALID_UUID", USER1); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_ENTITY_NOT_EXIST_CODE); Assert.assertEquals(ae.getDescription(), ACTION_ENTITY_NOT_EXIST); } @@ -953,6 +984,7 @@ public class ActionTest { actionManager .uploadArtifact(actionArtifact, testArtifactAction.getActionInvariantUuId(), USER1); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_ARTIFACT_ALREADY_EXISTS_CODE); Assert.assertEquals(ae.getDescription(), String .format(ACTION_ARTIFACT_ALREADY_EXISTS, testArtifactAction.getActionInvariantUuId())); @@ -965,6 +997,7 @@ public class ActionTest { actionManager .uploadArtifact(actionArtifact, testArtifactAction.getActionInvariantUuId(), USER2); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER); Assert.assertEquals(ae.getDescription(), "Versionable entity Action with id " + testArtifactAction.getActionInvariantUuId() + @@ -980,6 +1013,7 @@ public class ActionTest { actionManager .uploadArtifact(actionArtifact, testArtifactAction.getActionInvariantUuId(), USER1); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_UPDATE_ON_UNLOCKED_ENTITY); Assert.assertEquals(ae.getDescription(), "Can not update versionable entity Action with id " + testArtifactAction.getActionInvariantUuId() + " since it is not checked out."); @@ -1001,6 +1035,7 @@ public class ActionTest { try { ActionArtifact response = actionManager.downloadArtifact(actionUUID, artifactUUID); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE); } @@ -1012,6 +1047,7 @@ public class ActionTest { try { ActionArtifact response = actionManager.downloadArtifact(actionUUID, expectedArtifactUUID); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_ENTITY_NOT_EXIST_CODE); } @@ -1022,6 +1058,7 @@ public class ActionTest { try { actionManager.deleteArtifact("action2Id", "1234", USER1); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE); Assert.assertEquals(exception.getDescription(), ActionErrorConstants.ACTION_ENTITY_NOT_EXIST); } @@ -1032,6 +1069,7 @@ public class ActionTest { try { actionManager.deleteArtifact(action2Id, "1234", USER1); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE); Assert @@ -1055,6 +1093,7 @@ public class ActionTest { testArtifact.getArtifactUuId(), USER1); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_ARTIFACT_DELETE_READ_ONLY); Assert.assertEquals(exception.getDescription(), ActionErrorConstants.ACTION_ARTIFACT_DELETE_READ_ONLY_MSG); @@ -1076,6 +1115,7 @@ public class ActionTest { actionManager.deleteArtifact(testArtifactAction.getActionInvariantUuId(), actionArtifact.getArtifactUuId(), USER2); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE); Assert.assertEquals(ae.getDescription(), String.format(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER, USER1)); @@ -1088,6 +1128,7 @@ public class ActionTest { actionManager.deleteArtifact(testArtifactAction.getActionInvariantUuId(), actionArtifact.getArtifactUuId(), USER1); } catch (ActionException ae) { + logger.error(ae.getMessage()); Assert.assertEquals(ae.getErrorCode(), ACTION_NOT_LOCKED_CODE); Assert.assertEquals(ae.getDescription(), ACTION_NOT_LOCKED_MSG); } @@ -1107,6 +1148,7 @@ public class ActionTest { ActionArtifact response = actionManager .downloadArtifact(testArtifactAction.getActionUuId(), testArtifact.getArtifactUuId()); } catch (ActionException exception) { + logger.error(exception.getMessage()); Assert.assertEquals(exception.getErrorCode(), ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE); Assert @@ -1135,6 +1177,7 @@ public class ActionTest { updatedArtifact.setArtifactDescription("Test Artifact Update Description"); updatedArtifact.setArtifactProtection(ActionArtifactProtection.readWrite.name()); } catch (IOException exception) { + logger.error(exception.getMessage()); exception.printStackTrace(); } @@ -1164,6 +1207,7 @@ public class ActionTest { .updateArtifact(invalidActionArtifact, testArtifactAction.getActionInvariantUuId(), USER1); } catch (ActionException actionException) { + logger.error(actionException.getMessage()); Assert.assertEquals(actionException.getDescription(), ACTION_ARTIFACT_ENTITY_NOT_EXIST); } } @@ -1283,4 +1327,6 @@ public class ActionTest { return artifactUUID.toUpperCase(); } + */ + } |