aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditConsumerEventFuncTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java75
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineFuncTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEventFuncTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java117
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/monitoring/EsGatewayTest.java107
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/test/utils/TestConfigurationProvider.java30
15 files changed, 582 insertions, 11 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 665793b0ae..bfaccdd59e 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,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl;
import org.junit.Before;
@@ -19,6 +40,7 @@ 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.util.ThreadLocalsHolder;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
@@ -46,7 +68,7 @@ public class AuditConsumerEventFuncTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
consumer = new ConsumerDefinition();
consumer.setConsumerName(USER_ID);
ThreadLocalsHolder.setUuid(REQUEST_ID);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java
new file mode 100644
index 0000000000..203a70df78
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditingManagerTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.auditing.impl;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
+import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
+import org.openecomp.sdc.be.dao.impl.AuditingDao;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AuditingManagerTest {
+
+ private static final String MSG = "msg";
+ private String msg = "Any message";
+ private AuditingManager auditingManager;
+
+ @Mock
+ private AuditingGenericEvent auditEvent;
+ @Mock
+ private AuditingDao auditingDao;
+ @Mock
+ private AuditCassandraDao cassandraDao;
+ @Mock
+ private AuditEventFactory eventFactory;
+
+ @Before
+ public void setUp() throws Exception {
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
+ Mockito.when(eventFactory.getLogMessage()).thenReturn(msg);
+ Mockito.when(eventFactory.getDbEvent()).thenReturn(auditEvent);
+ Mockito.when(eventFactory.getAuditingEsType()).thenReturn(MSG);
+ Mockito.when(cassandraDao.saveRecord(auditEvent)).thenReturn(CassandraOperationStatus.OK);
+ Mockito.when(auditingDao.addRecord(auditEvent, MSG)).thenReturn(
+ ActionStatus.OK);
+ }
+
+ @Test
+ public void testShouldAuditEvent() {
+ String result = auditingManager.auditEvent(eventFactory);
+ assertThat(result, is(msg));
+ Mockito.verify(cassandraDao).saveRecord(auditEvent);
+ Mockito.verify(auditingDao).addRecord(auditEvent, MSG);
+ }
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java
index 9f08bbb72b..4c0a672f29 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFuncTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.category;
import org.junit.Before;
@@ -19,6 +40,7 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
import org.openecomp.sdc.be.resources.data.auditing.CategoryEvent;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.util.ThreadLocalsHolder;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -44,7 +66,7 @@ public class AuditCategoryEventFuncTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
ThreadLocalsHolder.setUuid(REQUEST_ID);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventTest.java
index 7f0f3f5a2f..f887355f37 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/category/AuditGetCategoryHierarchyEventTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.category;
import org.junit.Before;
@@ -18,6 +39,7 @@ 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.GetCategoryHierarchyEvent;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -42,7 +64,7 @@ public class AuditGetCategoryHierarchyEventTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineFuncTest.java
index 25cf1fbf11..f184c78c65 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineFuncTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineFuncTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.distribution;
import org.junit.Before;
@@ -20,6 +41,7 @@ import org.openecomp.sdc.be.resources.data.auditing.DistributionEngineEvent;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.be.resources.data.auditing.model.DistributionTopicData;
import org.openecomp.sdc.common.util.ThreadLocalsHolder;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -45,7 +67,7 @@ public class AuditDistributionEngineFuncTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
ThreadLocalsHolder.setUuid(REQUEST_ID);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEventFuncTest.java
index 4c9c63343f..ab3b054fd0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEventFuncTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEventFuncTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.distribution;
import org.junit.Before;
@@ -18,6 +39,7 @@ import org.openecomp.sdc.be.dao.impl.AuditingDao;
import org.openecomp.sdc.be.resources.data.auditing.*;
import org.openecomp.sdc.be.resources.data.auditing.model.*;
import org.openecomp.sdc.common.util.ThreadLocalsHolder;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -44,7 +66,7 @@ public class AuditDistributionEventFuncTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
ThreadLocalsHolder.setUuid(REQUEST_ID);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java
index 95beb9cb5b..ebae816845 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/ecompopenv/AuditEcompOpEnvEventTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.ecompopenv;
import org.junit.Before;
@@ -18,6 +39,7 @@ import org.openecomp.sdc.be.dao.impl.AuditingDao;
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.EcompOperationalEnvironmentEvent;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -44,7 +66,7 @@ public class AuditEcompOpEnvEventTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java
index a247d61d5c..7205b07020 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFuncTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.externalapi;
import org.junit.Before;
@@ -21,6 +42,7 @@ import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData;
import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -48,7 +70,7 @@ public class AuditExternalApiEventFuncTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java
index 781702c4a4..b6671fe429 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventFuncTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.resourceadmin;
import org.junit.Before;
@@ -24,6 +45,7 @@ import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.util.ThreadLocalsHolder;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -49,7 +71,7 @@ public class AuditResourceAdminEventFuncTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
ThreadLocalsHolder.setUuid(REQUEST_ID);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java
index 9652e884b4..3db93370af 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserEventFuncTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.auditing.impl.usersadmin;
import org.junit.Before;
@@ -18,6 +39,7 @@ import org.openecomp.sdc.be.dao.impl.AuditingDao;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.resources.data.auditing.*;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -43,7 +65,7 @@ public class AuditUserEventFuncTest {
@Before
public void setUp() {
init(esConfig);
- auditingManager = new AuditingManager(auditingDao, cassandraDao);
+ auditingManager = new AuditingManager(auditingDao, cassandraDao, new TestConfigurationProvider());
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
index fc93b40e1e..0f18de2ce5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransitionTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.lifecycle;
import org.junit.Test;
@@ -18,6 +39,7 @@ import org.openecomp.sdc.exception.ResponseFormat;
import fj.data.Either;
import mockit.Deencapsulation;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
public class CertificationRequestTransitionTest extends LifecycleTestBase {
@@ -25,7 +47,7 @@ public class CertificationRequestTransitionTest extends LifecycleTestBase {
private CertificationRequestTransition createTestSubject() {
return new CertificationRequestTransition(
- new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao())),
+ new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(), new TestConfigurationProvider())),
new ToscaElementLifecycleOperation(), new ServiceBusinessLogic(), new ToscaOperationFacade(), new TitanDao(new TitanGraphClient()));
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
new file mode 100644
index 0000000000..480c8cfec7
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.components.validation;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.impl.utils.ExceptionUtils;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.elements.Annotation;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.AnnotationTypeDefinition;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AnnotationValidatorTest {
+
+ private static final String TYPE = "type";
+ private static final String UNIQUE_ID = "1";
+ private static final String OWNER = "owner";
+ private static final String DESC = "desc";
+ private static final String TEST = "test";
+ private static final String PROP_NAME = "propName";
+ private Map<String, DataTypeDefinition> allData;
+ private List<PropertyDefinition> annotationTypeProperties;
+ private AnnotationValidator annotationValidator;
+ private List<PropertyDataDefinition> propertyDataDefinitions = new ArrayList<>();
+ private PropertyDataDefinition propertyDataDefinition = new PropertyDataDefinition();;
+
+ @Mock
+ private ComponentsUtils componentsUtils;
+ @Mock
+ private ApplicationDataTypeCache dataTypeCache;
+ @Mock
+ private PropertyValidator propertyValidator;
+ @Mock
+ private ExceptionUtils exceptionUtils;
+
+ @Before
+ public void setUp() throws Exception {
+ annotationValidator = new AnnotationValidator(propertyValidator, exceptionUtils, dataTypeCache, componentsUtils);
+ allData = Collections.emptyMap();
+ Either<Map<String, DataTypeDefinition>, TitanOperationStatus> cacheResponse = Either.left(allData);
+ Mockito.when(dataTypeCache.getAll()).thenReturn(cacheResponse);
+ annotationTypeProperties = Collections.emptyList();
+ propertyDataDefinitions = new ArrayList<>();
+ }
+
+ @Test
+ public void testValidateAnnotationsProperties() {
+ Annotation annotation = prepareAnnotation();
+ AnnotationTypeDefinition annotationTypeDefinition = prepareAnnotationTypeDefinition();
+ List<PropertyDefinition> properties = new ArrayList<>();
+ properties.add(new PropertyDefinition(propertyDataDefinition));
+
+ List<Annotation> annotations = annotationValidator
+ .validateAnnotationsProperties(annotation, annotationTypeDefinition);
+
+ Mockito.verify(propertyValidator).thinPropertiesValidator(properties, annotationTypeProperties, allData);
+ assertThat(annotations.get(0), is(annotation));
+ }
+
+ private AnnotationTypeDefinition prepareAnnotationTypeDefinition() {
+ AnnotationTypeDefinition annotationTypeDefinition = new AnnotationTypeDefinition();
+ annotationTypeDefinition.setProperties(annotationTypeProperties);
+ annotationTypeDefinition.setCreationTime(System.currentTimeMillis());
+ annotationTypeDefinition.setType(TYPE);
+ annotationTypeDefinition.setHighestVersion(true);
+ annotationTypeDefinition.setUniqueId(UNIQUE_ID);
+ annotationTypeDefinition.setOwnerId(OWNER);
+ annotationTypeDefinition.setDescription(DESC);
+ return annotationTypeDefinition;
+ }
+
+ private Annotation prepareAnnotation(){
+ Annotation annotation = new Annotation();
+ annotation.setName(TEST);
+ annotation.setDescription(DESC);
+ propertyDataDefinition.setName(PROP_NAME);
+ propertyDataDefinitions.add(propertyDataDefinition);
+ annotation.setProperties(propertyDataDefinitions);
+ annotation.setType(TYPE);
+ return annotation;
+ }
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
index 74ce6f1b49..fdcd6d8c75 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.impl;
import fj.data.Either;
@@ -31,6 +52,7 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
import java.util.List;
+import org.openecomp.sdc.test.utils.TestConfigurationProvider;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -38,7 +60,7 @@ import static org.mockito.Mockito.when;
public class ComponentsUtilsTest {
private ComponentsUtils createTestSubject() {
- return new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao()));
+ return new ComponentsUtils(new AuditingManager(new AuditingDao(), new AuditCassandraDao(), new TestConfigurationProvider()));
}
@Before
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/monitoring/EsGatewayTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/monitoring/EsGatewayTest.java
new file mode 100644
index 0000000000..71ee14f72b
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/monitoring/EsGatewayTest.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.monitoring;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.impl.MonitoringBusinessLogic;
+import org.openecomp.sdc.be.impl.WebAppContextWrapper;
+import org.openecomp.sdc.common.api.Constants;
+import org.springframework.web.context.WebApplicationContext;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EsGatewayTest {
+
+ private static final String MYWEBAPP = "/mywebapp";
+ private static final String SERVLET_MY_SERVLET = "/servlet/MyServlet";
+ private static final String PATH_INFO = "/a/b;c=123";
+ private static final String QUERY_STRING = "d=789";
+ private static final String PORT = "8080";
+ private static final String LOCALHOST = "localhost";
+ private EsGateway esGateway;
+
+ @Mock
+ HttpServletRequest request;
+ @Mock
+ ServletContext servletContext;
+ @Mock
+ HttpSession session;
+ @Mock
+ WebAppContextWrapper contextWrapper;
+ @Mock
+ WebApplicationContext webApplicationContext;
+ @Mock
+ MonitoringBusinessLogic monitoringBusinessLogic;
+
+ @Before
+ public void setUp() throws Exception {
+ esGateway = new EsGateway();
+ Mockito.when(request.getSession()).thenReturn(session);
+ Mockito.when(session.getServletContext()).thenReturn(servletContext);
+ Mockito.when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(contextWrapper);
+ Mockito.when(contextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
+ Mockito.when(webApplicationContext.getBean(MonitoringBusinessLogic.class)).thenReturn(monitoringBusinessLogic);
+ }
+
+ @Test
+ public void testShouldRewriteTarget() {
+ mockMonitoringBusinessLogic();
+ mockRequestParameters();
+ String redirectedUrl = esGateway.rewriteTarget(request);
+ assertThat(redirectedUrl, is("http://localhost:8080/mywebapp/servlet/MyServlet/a/b;c=123?d=789"));
+ }
+
+ @Test
+ public void testShouldGetModifiedUrl() {
+ mockMonitoringBusinessLogic();
+ mockRequestParameters();
+ String modifiedUrl = esGateway.getModifiedUrl(request);
+ assertThat(modifiedUrl, is("http://localhost:8080/mywebapp/servlet/MyServlet/a/b;c=123?d=789"));
+ }
+
+ @Test
+ public void shouldTestGetMonitoringBL() {
+ MonitoringBusinessLogic monitoringBL = esGateway.getMonitoringBL(servletContext);
+ assertThat(monitoringBL, is(notNullValue()));
+ }
+
+ private void mockMonitoringBusinessLogic(){
+ Mockito.when(monitoringBusinessLogic.getEsHost()).thenReturn(LOCALHOST);
+ Mockito.when(monitoringBusinessLogic.getEsPort()).thenReturn(PORT);
+ }
+
+ private void mockRequestParameters(){
+ Mockito.when(request.getContextPath()).thenReturn(MYWEBAPP);
+ Mockito.when(request.getServletPath()).thenReturn(SERVLET_MY_SERVLET);
+ Mockito.when(request.getPathInfo()).thenReturn(PATH_INFO);
+ Mockito.when(request.getQueryString()).thenReturn(QUERY_STRING);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/test/utils/TestConfigurationProvider.java b/catalog-be/src/test/java/org/openecomp/sdc/test/utils/TestConfigurationProvider.java
new file mode 100644
index 0000000000..f0130c6a83
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/test/utils/TestConfigurationProvider.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.test.utils;
+
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.auditing.impl.ConfigurationProvider;
+import org.openecomp.sdc.be.config.Configuration;
+
+public class TestConfigurationProvider extends ConfigurationProvider {
+ public Configuration getConfiguration() {
+ return Mockito.mock(Configuration.class);
+ }
+}