aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/test/java/org/openecomp/mso/client/sdno
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /common/src/test/java/org/openecomp/mso/client/sdno
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (diff)
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'common/src/test/java/org/openecomp/mso/client/sdno')
-rw-r--r--common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java94
-rw-r--r--common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java116
-rw-r--r--common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java59
3 files changed, 0 insertions, 269 deletions
diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java
deleted file mode 100644
index 6c64d90ff4..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.mso.client.sdno;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Optional;
-
-import org.junit.Test;
-import org.openecomp.mso.client.sdno.beans.SDNO;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class SDNOHealthCheckClientTest {
-
-
-
- private final String fileLocation = "src/test/resources/org/openecomp/mso/client/sdno/health-check/";
- private static final String userId = "test-user";
- private static final Optional<String> clliCode = Optional.of("test-clli");
- private static final String requestId = "test-request-id";
- private static final String configurationId = "test-configuration-id";
- private static final String interfaceId = "test-interface-id";
-
- @Test
- public void verfyLPortMirrorPreCheckRequest() throws IOException{
- String content = this.getJson("custom-lport-mirror-pre-check-request.json");
- ObjectMapper mapper = new ObjectMapper();
- SDNO expected = mapper.readValue(content, SDNO.class);
- SDNOHealthCheckClient client = new SDNOHealthCheckClient();
- String actual = client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId);
- assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
- }
-
- @Test
- public void verfyLPortMirrorPostCheckRequest() throws IOException{
- String content = this.getJson("custom-lport-mirror-post-check-request.json");
- ObjectMapper mapper = new ObjectMapper();
- SDNO expected = mapper.readValue(content, SDNO.class);
- SDNOHealthCheckClient client = new SDNOHealthCheckClient();
- String actual = client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId);
- assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
- }
-
-
- @Test
- public void verifyPortMirrorPostCheckRequest() throws IOException{
- String content = this.getJson("custom-port-mirror-post-check-request.json");
- ObjectMapper mapper = new ObjectMapper();
- SDNO expected = mapper.readValue(content, SDNO.class);
- SDNOHealthCheckClient client = new SDNOHealthCheckClient();
- String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId);
-
- assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
-
- }
- @Test
- public void verifyPortMirrorPreCheckRequest() throws IOException {
- String content = this.getJson("custom-port-mirror-pre-check-request.json");
- ObjectMapper mapper = new ObjectMapper();
- SDNO expected = mapper.readValue(content, SDNO.class);
- SDNOHealthCheckClient client = new SDNOHealthCheckClient();
- String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId);
-
- assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
-
- }
-
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
- }
-
-}
diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java
deleted file mode 100644
index cd84e7854d..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.mso.client.sdno;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.UUID;
-
-import org.hamcrest.core.StringContains;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.openecomp.mso.client.dmaap.Consumer;
-import org.openecomp.mso.client.dmaap.exceptions.DMaaPConsumerFailure;
-import org.openecomp.mso.client.exceptions.SDNOException;
-import org.openecomp.mso.client.sdno.beans.SDNO;
-import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-
-public class SDNOValidatorTest {
-
-
- @Mock private Consumer mrConsumer;
- @Spy private SDNOHealthCheckDmaapConsumer dmaapConsumer;
- private final String fileLocation = "src/test/resources/org/openecomp/mso/client/sdno/";
- private final String uuid = "xyz123";
- @Rule public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void setUpTests() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void success() throws IOException, Exception {
- when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer);
- when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-success.json")}));
-
- SDNOValidatorImpl validator = new SDNOValidatorImpl();
- SDNOValidatorImpl spy = spy(validator);
- when(dmaapConsumer.getRequestId()).thenReturn("xyz123");
- doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class));
- boolean result = spy.pollForResponse("xyz123");
- assertEquals("result is true", result, true);
- }
-
- @Test
- public void failure() throws IOException, Exception {
- when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer);
- when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-failure.json")}));
-
- SDNOValidatorImpl validator = new SDNOValidatorImpl();
- SDNOValidatorImpl spy = spy(validator);
- when(dmaapConsumer.getRequestId()).thenReturn("xyz123");
- doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class));
- thrown.expect(SDNOException.class);
- thrown.expectMessage(new StringContains("my error message"));
- boolean result = spy.pollForResponse("xyz123");
-
- }
- @Ignore
- @Test
- public void run() throws Exception {
- SDNOValidatorImpl validator = new SDNOValidatorImpl();
- UUID uuid = UUID.randomUUID();
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("test");
- vnf.setIpv4OamAddress("1.2.3.4");
- vnf.setVnfType("VPE");
- SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid");
- ObjectMapper mapper = new ObjectMapper();
- String json = mapper.writeValueAsString(request);
- validator.submitRequest(json);
- thrown.expect(DMaaPConsumerFailure.class);
- boolean result = validator.pollForResponse(uuid.toString());
- System.out.println(json);
-
- }
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
- }
-}
diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java
deleted file mode 100644
index 4a2580f3f1..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.client.sdno.beans;
-
-import org.junit.Test;
-
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.PojoClassFilter;
-import com.openpojo.reflection.filters.FilterEnum;
-import com.openpojo.reflection.filters.FilterPackageInfo;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-
-public class SdnoBeansTest {
-
- private PojoClassFilter filterTestClasses = new FilterTestClasses();
-
- @Test
- public void pojoStructure() {
- test("org.openecomp.mso.client.sdno.beans");
- }
-
- private void test(String pojoPackage) {
- Validator validator = ValidatorBuilder.create()
- .with(new GetterMustExistRule())
- .with(new SetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
- validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses);
- }
- private static class FilterTestClasses implements PojoClassFilter {
- public boolean include(PojoClass pojoClass) {
- return !pojoClass.getSourcePath().contains("/test-classes/");
- }
- }
-}