summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai <lukai@chinamobile.com>2020-02-17 18:15:09 +0800
committerKai <lukai@chinamobile.com>2020-02-17 18:16:57 +0800
commit24feebbfc962f2bab0773c561164d1f3bf947e2a (patch)
tree33d471e8dfdad5c9280965b56c7e4bcc27648088
parentc57f0d90087776d1fb4422bd6c3b85db54f642e3 (diff)
unit test for tca-gen2
Issue-ID: DCAEGEN2-1900 Signed-off-by: Kai Lu <lukai@chinamobile.com> Change-Id: I8b86a5c2f4ee1cf195ee8a7a5e44c625daef1361
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/BaseTcaWebTest.java28
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/TcaAppPropertiesTest.java47
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentContext.java36
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentService.java41
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementContext.java46
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementEntity.java41
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementRepository.java48
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java113
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaAppPropertiesValidatorTest.java47
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java54
-rw-r--r--dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProviderTest.java47
11 files changed, 548 insertions, 0 deletions
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/BaseTcaWebTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/BaseTcaWebTest.java
new file mode 100644
index 0000000..65279c8
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/BaseTcaWebTest.java
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2020 ChinaMobile. 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.onap.dcae.analytics.tca.web;
+
+import org.onap.dcae.analytics.test.BaseAnalyticsUnitTest;
+
+/**
+ * @author Kai Lu
+ */
+public class BaseTcaWebTest extends BaseAnalyticsUnitTest {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/TcaAppPropertiesTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/TcaAppPropertiesTest.java
new file mode 100644
index 0000000..d99d6b3
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/TcaAppPropertiesTest.java
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2020 ChinaMobile. All rights reserved.
+ * ================================================================================
+ * Copyright Copyright (c) 2019 IBM
+ * ================================================================================
+ * 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.onap.dcae.analytics.tca.web;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.test.BaseAnalyticsSpringBootIT;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.test.context.ActiveProfiles;
+
+@ActiveProfiles({AnalyticsProfile.DEV_PROFILE_NAME})
+public class TcaAppPropertiesTest extends BaseAnalyticsSpringBootIT{
+
+ @Autowired
+ Environment environment;
+
+ @Test
+ void TestTcaAppProperties() {
+ TcaAppProperties properties = new TcaAppProperties(environment);
+ Assertions.assertNotNull(properties.getTca());
+ Assertions.assertNotNull(properties.getStreamsPublishes());
+ Assertions.assertNotNull(properties.getStreamsSubscribes());
+ Assertions.assertNotNull(properties.getTca().getAai());
+ Assertions.assertEquals(true, properties.getTca().getEnableAbatement());
+ Assertions.assertEquals(false, properties.isConfigBindingServiceProfileActive());
+ }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentContext.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentContext.java
new file mode 100644
index 0000000..1d530ef
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentContext.java
@@ -0,0 +1,36 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 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=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.domain;
+
+import lombok.Data;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAaiEnrichmentContext implements TcaAaiEnrichmentContext {
+
+ private boolean isAaiEnrichmentEnabled = true;
+ private TcaAaiEnrichmentService aaiEnrichmentService = new TestTcaAaiEnrichmentService();
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentService.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentService.java
new file mode 100644
index 0000000..8555d46
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAaiEnrichmentService.java
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 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=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.domain;
+
+import lombok.Data;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAaiEnrichmentService implements TcaAaiEnrichmentService {
+
+ private TcaAlert enrichedTcaAlert;
+
+ @Override
+ public TcaAlert doAaiEnrichment(final TcaExecutionContext tcaExecutionContext) {
+ final TcaAlert tcaAlert = tcaExecutionContext.getTcaResultContext().getTcaAlert();
+ return enrichedTcaAlert == null ? tcaAlert : enrichedTcaAlert;
+ }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementContext.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementContext.java
new file mode 100644
index 0000000..c8adb3d
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementContext.java
@@ -0,0 +1,46 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 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=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.domain;
+
+import lombok.Data;
+
+import java.util.Date;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAbatementContext implements TcaAbatementContext {
+
+ private boolean isAbatementEnabled = true;
+ private TcaAbatementRepository tcaAbatementRepository = new TestTcaAbatementRepository();
+
+
+ @Override
+ public TcaAbatementEntity create(
+ final String lookupKey, final String requestId, final boolean isAbatementAlertSent) {
+ return new TestTcaAbatementEntity(new Date(), lookupKey, requestId, isAbatementAlertSent);
+ }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementEntity.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementEntity.java
new file mode 100644
index 0000000..c769a96
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementEntity.java
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 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=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.Date;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+@AllArgsConstructor
+public class TestTcaAbatementEntity implements TcaAbatementEntity {
+
+ private Date lastModificationDate;
+ private String lookupKey;
+ private String requestId;
+ private boolean isAbatementAlertSent;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementRepository.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementRepository.java
new file mode 100644
index 0000000..e608584
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/domain/TestTcaAbatementRepository.java
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 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=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.domain;
+
+import lombok.Data;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAbatementRepository implements TcaAbatementRepository {
+
+ private List<TcaAbatementEntity> testLookupAbatementEntities = new LinkedList<>();
+
+ @Override
+ public void save(final TcaAbatementEntity tcaAbatementEntity) {
+ // do nothing
+ }
+
+ @Override
+ public List<TcaAbatementEntity> findByLookupKey(final String lookUpKey) {
+ return testLookupAbatementEntities;
+ }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java
new file mode 100644
index 0000000..8d1b45c
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java
@@ -0,0 +1,113 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2020 ChinaMobile. All rights reserved.
+ * ================================================================================
+ * Copyright Copyright (c) 2019 IBM
+ * ================================================================================
+ * 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.onap.dcae.analytics.tca.web.integration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaExecutionContext.GenericTcaExecutionContextBuilder;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaProcessingContext;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaResultContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaProcessingContext;
+import org.onap.dcae.analytics.tca.core.service.TcaResultContext;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion;
+import org.onap.dcae.analytics.tca.web.BaseTcaWebTest;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.domain.TestTcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.web.domain.TestTcaAbatementContext;
+import org.onap.dcae.analytics.test.BaseAnalyticsSpringBootIT;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageHeaders;
+
+public class TcaAlertTransformerTest extends BaseAnalyticsSpringBootIT {
+
+ @Autowired
+ Environment environment;
+
+ protected static final String TEST_POLICY_JSON_STRING;
+ protected static final String TEST_REQUEST_ID = "testRequestId";
+ protected static final TcaPolicy TEST_TCA_POLICY;
+
+ static {
+
+ TEST_POLICY_JSON_STRING = fromStream(TestFileLocation.TCA_POLICY_JSON);
+ TEST_TCA_POLICY = TcaModelJsonConversion.TCA_POLICY_JSON_FUNCTION.apply(TEST_POLICY_JSON_STRING)
+ .orElseThrow(() -> new IllegalStateException("Unable to get Test TcaPolicy"));
+ }
+
+ @Test
+ void TestTcaAppPropertiesValidator() throws Exception {
+ TcaAppProperties properties = new TcaAppProperties(environment);
+
+ final Message message = Mockito.mock(Message.class);
+ MessageHeaders header = Mockito.mock(MessageHeaders.class);
+
+
+ final TcaExecutionContext testExecutionContext =
+ getTestExecutionContext(BaseTcaWebTest.fromStream("data/json/cef/cef_message.json"));
+
+ List<TcaExecutionContext> messagePayload = new ArrayList<TcaExecutionContext>();
+ messagePayload.add(testExecutionContext);
+
+ Mockito.when(message.getPayload()).thenReturn(messagePayload);
+ Mockito.when(message.getHeaders()).thenReturn(header);
+ Mockito.when(AnalyticsHttpUtils.getRequestId(header)).thenReturn("resuestId-1");
+ Mockito.when(AnalyticsHttpUtils.getTransactionId(header)).thenReturn("transactionId-1");
+ Mockito.when(header.get(AnalyticsHttpConstants.REQUEST_BEGIN_TS_HEADER_KEY)).thenReturn(null);
+
+ TcaAlertTransformer tcaAlertTransformer = new TcaAlertTransformer(properties);
+ tcaAlertTransformer.doTransform(message);
+
+ }
+
+ protected TcaExecutionContext getTestExecutionContext(final String cefMessage) {
+ final TestTcaAbatementContext testTcaAbatementContext = new TestTcaAbatementContext();
+ return getTestExecutionContextBuilder(cefMessage, TEST_TCA_POLICY, testTcaAbatementContext).build();
+ }
+
+ protected GenericTcaExecutionContextBuilder getTestExecutionContextBuilder(
+ final String cefMessage, final TcaPolicy tcaPolicy, final TcaAbatementContext tcaAbatementContext) {
+
+ final TcaProcessingContext tcaProcessingContext = new GenericTcaProcessingContext();
+ final TcaResultContext tcaResultContext = new GenericTcaResultContext();
+ final TestTcaAaiEnrichmentContext testTcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext();
+
+ return GenericTcaExecutionContext.builder()
+ .requestId(TEST_REQUEST_ID)
+ .cefMessage(cefMessage)
+ .tcaPolicy(tcaPolicy)
+ .tcaProcessingContext(tcaProcessingContext)
+ .tcaResultContext(tcaResultContext)
+ .tcaAbatementContext(tcaAbatementContext)
+ .tcaAaiEnrichmentContext(testTcaAaiEnrichmentContext);
+ }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaAppPropertiesValidatorTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaAppPropertiesValidatorTest.java
new file mode 100644
index 0000000..3792e23
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaAppPropertiesValidatorTest.java
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2020 ChinaMobile. All rights reserved.
+ * ================================================================================
+ * Copyright Copyright (c) 2019 IBM
+ * ================================================================================
+ * 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.onap.dcae.analytics.tca.web.validation;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.test.BaseAnalyticsSpringBootIT;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.validation.Errors;
+
+@ActiveProfiles({AnalyticsProfile.DEV_PROFILE_NAME})
+public class TcaAppPropertiesValidatorTest extends BaseAnalyticsSpringBootIT {
+
+ @Autowired
+ Environment environment;
+
+ @Test
+ void TestTcaAppPropertiesValidator() {
+ TcaAppProperties properties = new TcaAppProperties(environment);
+ TcaAppPropertiesValidator validate = new TcaAppPropertiesValidator();
+ Errors errors = Mockito.mock(Errors.class);
+ validate.validate(properties, errors);
+ }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java
new file mode 100644
index 0000000..36ed37e
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2020 ChinaMobile. All rights reserved.
+ * ================================================================================
+ * Copyright Copyright (c) 2019 IBM
+ * ================================================================================
+ * 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.onap.dcae.analytics.tca.web.validation;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper;
+import org.onap.dcae.analytics.test.BaseAnalyticsSpringBootIT;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.validation.Errors;
+
+@ActiveProfiles({AnalyticsProfile.DEV_PROFILE_NAME})
+public class TcaPolicyValidateTest extends BaseAnalyticsSpringBootIT {
+
+ @Autowired
+ Environment environment;
+
+ @Test
+ void TestTcaAppPropertiesValidator() {
+ TcaAppProperties properties = new TcaAppProperties(environment);
+ TcaPolicyValidator validate = new TcaPolicyValidator();
+ Errors errors = Mockito.mock(Errors.class);
+ TcaPolicyWrapper tcaPolicyWrapper = new TcaPolicyWrapper(properties);
+ tcaPolicyWrapper.getConfigSource();
+ TcaPolicy tcaPolicy = tcaPolicyWrapper.getTcaPolicy();
+ validate.validate(tcaPolicy, errors);
+ validate.apply(tcaPolicy);
+ Assertions.assertEquals("version-0", tcaPolicyWrapper.getPolicyVersion());
+ }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProviderTest.java b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProviderTest.java
new file mode 100644
index 0000000..3a6aad8
--- /dev/null
+++ b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProviderTest.java
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2020 ChinaMobile. All rights reserved.
+ * ================================================================================
+ * Copyright Copyright (c) 2019 IBM
+ * ================================================================================
+ * 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.onap.dcae.analytics.web.dmaap;
+
+import java.net.URL;
+import java.util.Arrays;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.springframework.http.HttpHeaders;
+
+public class MrTriggerMessageProviderTest {
+
+ @Test
+ void getMrTriggerMessageProviderTest() throws Exception {
+ URL proxyURL = new URL("http://localhost");
+ MrSubscriberPollingPreferences pollingPreferences = Mockito.mock(MrSubscriberPollingPreferences.class);
+ HttpHeaders headers = Mockito.mock(HttpHeaders.class);
+ MrSubscriberPreferences subscriberPreferences =
+ new MrSubscriberPreferences("http://localhost:8080",
+ "TestClientId", headers,
+ "TestUserName", "TestPassword",
+ proxyURL, true, false, "TestGroup",
+ Arrays.asList("TestId1", "TestId2"),
+ new Integer(4), new Integer(3), pollingPreferences);
+ Assertions.assertNotNull(new MrTriggerMessageProvider(subscriberPreferences).getTriggerMessage());
+ }
+}