From 3159c0a22841e812d20dc8a24313222fa863315f Mon Sep 17 00:00:00 2001 From: "BOSLET, CORY" Date: Mon, 1 Mar 2021 10:21:07 -0500 Subject: remove unused endpoints from source code Removed unused endpoints from source code Removed unused jackson mapper configuration Issue-ID: SO-3557 Signed-off-by: AT&T Open Source Change-Id: I32df4e49f5adf8cade8d963492495975fc0f11b2 --- .../adapters/tenant/MsoTenantAdapterImplTest.java | 71 ------ .../so/adapters/tenant/TenantAdapterRestTest.java | 240 --------------------- .../tenant/exceptions/TenantAlreadyExistsTest.java | 29 --- .../tenant/exceptions/TenantExceptionBeanTest.java | 44 ---- .../tenant/exceptions/TenantExceptionTest.java | 46 ---- 5 files changed, 430 deletions(-) delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java (limited to 'adapters/mso-openstack-adapters/src/test/java') diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java deleted file mode 100644 index b695a538bb..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.so.adapters.tenant; - -import java.util.HashMap; -import javax.xml.ws.Holder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.adapters.tenantrest.TenantRollback; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.entity.MsoRequest; - -@RunWith(MockitoJUnitRunner.class) -public class MsoTenantAdapterImplTest { - - @Mock - private CloudConfig cloudConfig; - - @Spy - @InjectMocks - private MsoTenantAdapterImpl msoTenantAdapter; - - @Test - public void healthCheck() throws Exception { - msoTenantAdapter.healthCheck(); - } - - @Test(expected = NullPointerException.class) - public void createTenant() throws Exception { - msoTenantAdapter.createTenant("site", "tenant", new HashMap<>(), true, true, new MsoRequest(), - new Holder(), new Holder()); - } - - @Test(expected = NullPointerException.class) - public void queryTenant() throws Exception { - msoTenantAdapter.queryTenant("site", "tenant", new MsoRequest(), new Holder<>(), new Holder<>(), - new Holder<>()); - } - - @Test(expected = NullPointerException.class) - public void deleteTenant() throws Exception { - msoTenantAdapter.deleteTenant("cloud", "tenant", new MsoRequest(), new Holder()); - } - - @Test - public void rollbackTenant() throws Exception { - msoTenantAdapter.rollbackTenant(new TenantRollback()); - } - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java deleted file mode 100644 index 1a44934187..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java +++ /dev/null @@ -1,240 +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.onap.so.adapters.tenant; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteTenantById_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetMetadata_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetRoles_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantById_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantById_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantByName_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantByName_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetUser_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostMetadata_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostTenantWithBodyFile_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostTenant_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutRolesAdmin_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccessAdmin; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.so.adapters.tenantrest.CreateTenantRequest; -import org.onap.so.adapters.tenantrest.CreateTenantResponse; -import org.onap.so.adapters.tenantrest.DeleteTenantRequest; -import org.onap.so.adapters.tenantrest.DeleteTenantResponse; -import org.onap.so.adapters.vnf.BaseRestTestUtils; -import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.entity.MsoRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -public class TenantAdapterRestTest extends BaseRestTestUtils { - - @Autowired - private JettisonStyleMapperProvider jettisonTypeObjectMapper; - - @Test - public void testCreateTenantCreated() throws JsonParseException, JsonMappingException, IOException { - - CreateTenantRequest request = new CreateTenantRequest(); - String cloudSiteId = "mtn13"; - String requestId = "62265093-277d-4388-9ba6-449838ade586"; - String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; - String tenantName = "testingTenantName"; - boolean failIfExists = true; - boolean backout = true; - Map metaData = new HashMap<>(); - metaData.put("key1", "value2"); - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setMsoRequest(msoReq); - request.setTenantName(tenantName); - request.setMetadata(metaData); - request.setBackout(backout); - request.setFailIfExists(failIfExists); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantByName_404(wireMockServer, tenantName); - - mockOpenStackPostTenantWithBodyFile_200(wireMockServer); - - mockOpenStackGetUser_200(wireMockServer, "m93945"); - - mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM"); - - mockOpenStackPutRolesAdmin_200(wireMockServer, "OS-KSADM"); - - mockOpenStackPostMetadata_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/tenants"), HttpMethod.POST, entity, CreateTenantResponse.class); - - CreateTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateTenantResponse_Created.json"), CreateTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testCreateTenantExists() throws JsonParseException, JsonMappingException, IOException { - - CreateTenantRequest request = new CreateTenantRequest(); - String cloudSiteId = "mtn13"; - String requestId = "62265093-277d-4388-9ba6-449838ade586"; - String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; - String tenantName = "testingTenantName"; - boolean failIfExists = false; - boolean backout = true; - Map metadata = new HashMap<>(); - - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setMsoRequest(msoReq); - request.setTenantName(tenantName); - request.setMetadata(metadata); - request.setBackout(backout); - request.setFailIfExists(failIfExists); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantByName_200(wireMockServer, tenantName); - - mockOpenStackPostTenant_200(wireMockServer); - - mockOpenStackGetMetadata_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/tenants"), HttpMethod.POST, entity, CreateTenantResponse.class); - - CreateTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateTenantResponse_Exists.json"), CreateTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testDeleteTenant() throws IOException { - - DeleteTenantRequest request = new DeleteTenantRequest(); - String cloudSiteId = "mtn13"; - String tenantId = "tenantId"; - String requestId = "ra1"; - String serviceInstanceId = "sa1"; - - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setTenantId(tenantId); - request.setMsoRequest(msoReq); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantById_200(wireMockServer, tenantId); - - mockOpenStackDeleteTenantById_200(wireMockServer, tenantId); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/tenants/tenantId"), HttpMethod.DELETE, - entity, DeleteTenantResponse.class); - - DeleteTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/DeleteTenantResponse_Success.json"), DeleteTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - // @Ignore - @Test - public void testDeleteTenantFails() throws IOException { - - DeleteTenantRequest request = new DeleteTenantRequest(); - String cloudSiteId = "mtn13"; - String tenantId = "tenantId"; - String requestId = "ra1"; - String serviceInstanceId = "sa1"; - - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setTenantId(tenantId); - request.setMsoRequest(msoReq); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantById_404(wireMockServer, tenantId); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/tenants/tenantId"), HttpMethod.DELETE, - entity, DeleteTenantResponse.class); - - DeleteTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/DeleteTenantResponse_Failed.json"), DeleteTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Ignore - @Test - public void testQuaryTenant() { - - - - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java deleted file mode 100644 index 106a96a091..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ 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.so.adapters.tenant.exceptions; - -import org.junit.Test; -import static org.junit.Assert.*; - -public class TenantAlreadyExistsTest { - - @Test - public void test() { - TenantAlreadyExists tar = new TenantAlreadyExists("name", "cloudId", "tenantId"); - assert (tar != null); - assertNotNull(tar); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java deleted file mode 100644 index ece92b4ac0..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ 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.so.adapters.tenant.exceptions; - -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import static org.junit.Assert.*; - -public class TenantExceptionBeanTest { - - @Mock - private MsoExceptionCategory mec; - - @InjectMocks - private TenantExceptionBean teb; - - @Test - public void test() { - teb = new TenantExceptionBean("message", mec); - teb.setMessage("message"); - teb.setCategory(MsoExceptionCategory.INTERNAL); - teb.setCategory(MsoExceptionCategory.IO); - teb.setCategory(MsoExceptionCategory.OPENSTACK); - teb.setCategory(MsoExceptionCategory.USERDATA); - assert (teb.getMessage().equals("message")); - assert (teb.getCategory() != null); - assertNotNull(teb); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java deleted file mode 100644 index 1ce4c664ac..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ 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.so.adapters.tenant.exceptions; - -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import static org.junit.Assert.*; - -public class TenantExceptionTest { - - @Mock - private TenantExceptionBean teb; - - @Mock - private MsoExceptionCategory mec; - - @InjectMocks - private TenantException te; - - @Test - public void test() { - teb = new TenantExceptionBean("message"); - teb.setMessage("message"); - teb.setCategory(MsoExceptionCategory.INTERNAL); - te = new TenantException("message", mec); - te.setFaultInfo(teb); - assert (te.getFaultInfo() != null); - assert (te.getFaultInfo().equals(teb)); - assertNotNull(teb); - } -} -- cgit 1.2.3-korg