summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java72
1 files changed, 10 insertions, 62 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java
index bf3c7c4e2a..665793b0ae 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java
@@ -1,28 +1,5 @@
package org.openecomp.sdc.be.auditing.impl;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.CONSUMER_NAME;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.CONSUMER_PASSWORD;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.CONSUMER_SALT;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.DESCRIPTION;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_ADD_ECOMP_USER_CRED_LOG_STR;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.EXPECTED_GET_ECOMP_USER_CRED_LOG_STR;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.MODIFIER_UID;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.REQUEST_ID;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.SERVICE_INSTANCE_ID;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.STATUS_OK;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.USER_ID;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.init;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.modifier;
-
-import java.util.EnumMap;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,13 +18,19 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
import org.openecomp.sdc.be.resources.data.auditing.ConsumerEvent;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import org.openecomp.sdc.common.util.ThreadLocalsHolder;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.*;
+
@RunWith(MockitoJUnitRunner.class)
public class AuditConsumerEventFuncTest {
private AuditingManager auditingManager;
-
private ConsumerDefinition consumer;
@Mock
@@ -58,7 +41,7 @@ public class AuditConsumerEventFuncTest {
private static Configuration.ElasticSearchConfig esConfig;
@Captor
- private ArgumentCaptor<AuditingGenericEvent> eventCaptor;
+ private ArgumentCaptor<ConsumerEvent> eventCaptor;
@Before
public void setUp() {
@@ -90,17 +73,6 @@ public class AuditConsumerEventFuncTest {
}
@Test
- public void testOldAddEcompUserCredEvent() {
- when(auditingDao.addRecord(anyMap(), eq(AuditingActionEnum.ADD_ECOMP_USER_CREDENTIALS.getAuditingEsType())))
- .thenReturn(ActionStatus.OK);
- when(cassandraDao.saveRecord(any(AuditingGenericEvent.class))).thenReturn(CassandraOperationStatus.OK);
-
- assertThat(auditingManager.auditEvent(fillMap(AuditingActionEnum.ADD_ECOMP_USER_CREDENTIALS))).isEqualTo(EXPECTED_ADD_ECOMP_USER_CRED_LOG_STR);
- verifyConsumerEvent(AuditingActionEnum.ADD_ECOMP_USER_CREDENTIALS.getName());
-
- }
-
- @Test
public void testNewGetEcompUserCredEvent() {
AuditEventFactory factory = new AuditConsumerEventFactory(
AuditingActionEnum.GET_ECOMP_USER_CREDENTIALS,
@@ -121,17 +93,6 @@ public class AuditConsumerEventFuncTest {
}
@Test
- public void testOldGetEcompUserCredEvent() {
- when(auditingDao.addRecord(anyMap(), eq(AuditingActionEnum.GET_ECOMP_USER_CREDENTIALS.getAuditingEsType())))
- .thenReturn(ActionStatus.OK);
- when(cassandraDao.saveRecord(any(AuditingGenericEvent.class))).thenReturn(CassandraOperationStatus.OK);
-
- assertThat(auditingManager.auditEvent(fillMap(AuditingActionEnum.GET_ECOMP_USER_CREDENTIALS))).isEqualTo(EXPECTED_GET_ECOMP_USER_CRED_LOG_STR);
- verifyConsumerEvent(AuditingActionEnum.GET_ECOMP_USER_CREDENTIALS.getName());
-
- }
-
- @Test
public void buildConsumerNameWhenAllFieldsAreProvided() {
consumer.setConsumerName(CONSUMER_NAME);
consumer.setConsumerSalt(CONSUMER_SALT);
@@ -173,22 +134,9 @@ public class AuditConsumerEventFuncTest {
assertEquals("", AuditConsumerEventFactory.buildConsumerName(null));
}
-
- private EnumMap<AuditingFieldsKeysEnum, Object> fillMap(AuditingActionEnum action) {
- EnumMap<AuditingFieldsKeysEnum, Object> auditingFields = new EnumMap<>(AuditingFieldsKeysEnum.class);
- auditingFields.put(AuditingFieldsKeysEnum.AUDIT_ACTION, action.getName());
- auditingFields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_NAME, modifier.getFirstName() + " " + modifier.getLastName());
- auditingFields.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID, modifier.getUserId());
- auditingFields.put(AuditingFieldsKeysEnum.AUDIT_STATUS, STATUS_OK);
- auditingFields.put(AuditingFieldsKeysEnum.AUDIT_DESC, DESCRIPTION);
- auditingFields.put(AuditingFieldsKeysEnum.AUDIT_ECOMP_USER, USER_ID);
-
- return auditingFields;
- }
-
private void verifyConsumerEvent(String action) {
verify(cassandraDao).saveRecord(eventCaptor.capture());
- ConsumerEvent storedEvent = (ConsumerEvent) eventCaptor.getValue();
+ ConsumerEvent storedEvent = eventCaptor.getValue();
assertThat(storedEvent.getModifier()).isEqualTo(MODIFIER_UID);
assertThat(storedEvent.getDesc()).isEqualTo(DESCRIPTION);
assertThat(storedEvent.getStatus()).isEqualTo(STATUS_OK);