diff options
Diffstat (limited to 'adapters/mso-vfc-adapter/src/test/java')
15 files changed, 82 insertions, 113 deletions
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java index efd3359821..c0305f18de 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java @@ -1,42 +1,36 @@ /* -* ============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 + * ============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 + * 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. + * 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.vfc.exceptions; import static org.junit.Assert.*; - import org.junit.Test; public class ApplicationExceptionTest { - private ApplicationException application = new ApplicationException(500,null); - - @Test - public void testApplicationException() { - application.setErrorCode(500); - application.setErrorMsg("ErrorMsg"); - assertEquals(application.getErrorCode(), 500); - assertEquals(application.getErrorMsg(), "ErrorMsg"); - } - - @Test - public void testbuildErrorResponse(){ - assert(application.buildErrorResponse()!=null); - } + private ApplicationException application = new ApplicationException(500, null); + + @Test + public void testApplicationException() { + application.setErrorCode(500); + application.setErrorMsg("ErrorMsg"); + assertEquals(application.getErrorCode(), 500); + assertEquals(application.getErrorMsg(), "ErrorMsg"); + } + + @Test + public void testbuildErrorResponse() { + assert (application.buildErrorResponse() != null); + } } diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java index 2acd6c25ad..548d8b3645 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java @@ -46,4 +46,4 @@ public class CustomerModelTest { customerModel.setServiceType("service"); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java index ef5eb2617e..2b217469e5 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java @@ -46,4 +46,4 @@ public class LocationConstraintTest { locationConstraint.setLocationConstraints(new VimLocation()); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java index 2e720e47ad..082d4e69f4 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java @@ -66,4 +66,4 @@ public class NSResourceInputParameterTest { nsResourceInputParameter.setNsOperationKey(new NsOperationKey()); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java index caf2d7e164..c2e6b583af 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java @@ -66,4 +66,4 @@ public class NsCreateReqTest { nsCreateReq.setDescription("desc"); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java index 330e34d0cc..70e54a1c09 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java @@ -36,4 +36,4 @@ public class NsInstantiateReqTest { nsInstantiateReq.setNsInstanceId("test"); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java index e315eefbcc..a8939f8996 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java @@ -76,4 +76,4 @@ public class NsOperationKeyTest { nsOperationKey.setNodeTemplateUUID("nodeTemplateid"); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java index 852bac29a1..45c46edd0d 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java @@ -20,7 +20,6 @@ package org.onap.so.adapters.vfc.model; import org.junit.Test; - import java.util.Collections; import java.util.HashMap; @@ -49,4 +48,4 @@ public class NsParametersTest { nsParameters.setAdditionalParamForNs(new HashMap<>()); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java index e99d9aef38..b1040ef463 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java @@ -20,7 +20,6 @@ package org.onap.so.adapters.vfc.model; import org.junit.Test; - import java.util.Arrays; public class NsProgressStatusTest { @@ -58,4 +57,4 @@ public class NsProgressStatusTest { nsProgressStatus.setResponseHistoryList(Arrays.asList(new ResponseDescriptor())); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java index a9f2f4ce3c..3f2f73531c 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java @@ -76,4 +76,4 @@ public class ResponseDescriptorTest { responseDescriptor.setResponseId(1); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java index 61ddac2707..64f8da65b4 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java @@ -20,7 +20,6 @@ package org.onap.so.adapters.vfc.model; import org.junit.Test; - import java.util.HashMap; public class RestfulResponseTest { @@ -73,4 +72,4 @@ public class RestfulResponseTest { restfulResponse.setResponseContent("responseString"); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java index e9b250717d..85d3a136af 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java @@ -36,4 +36,4 @@ public class VimLocationTest { vimLocation.setVimId("vimid"); } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java index 50bf3f97b0..feb40f73e0 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java @@ -19,10 +19,10 @@ */ package org.onap.so.adapters.vfc.rest; + import ch.vorburger.exec.ManagedProcessException; import ch.vorburger.mariadb4j.DBConfigurationBuilder; import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; - import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.jdbc.DataSourceBuilder; @@ -37,17 +37,14 @@ import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; - import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; @Configuration @Profile({"test"}) @EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", - basePackages = { "org.onap.so.db.request.data.repository"} - ) +@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory", + transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"}) public class EmbeddedMariaDbConfig { @Bean @@ -56,47 +53,34 @@ public class EmbeddedMariaDbConfig { } @Primary - @Bean(name = "requestDataSource") - @ConfigurationProperties(prefix = "spring.datasource") + @Bean(name = "requestDataSource") + @ConfigurationProperties(prefix = "spring.datasource") DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, - @Value("${mariaDB4j.databaseName}") String databaseName, - @Value("${spring.datasource.username}") String datasourceUsername, - @Value("${spring.datasource.password}") String datasourcePassword, - @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { - //Create our database with default root user and no password + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + // Create our database with default root user and no password mariaDB4jSpringService.getDB().createDB(databaseName); DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); - return DataSourceBuilder - .create() - .username(datasourceUsername) - .password(datasourcePassword) - .url(config.getURL(databaseName)) - .driverClassName(datasourceDriver) - .build(); + return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword) + .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build(); } - @Primary - @Bean(name = "requestEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean - entityManagerFactory( - EntityManagerFactoryBuilder builder, - @Qualifier("requestDataSource") DataSource dataSource - ) { - return builder - .dataSource(dataSource) - .packages("org.onap.so.db.request.beans") - .persistenceUnit("requestDB") - .build(); - } + @Primary + @Bean(name = "requestEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, + @Qualifier("requestDataSource") DataSource dataSource) { + return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB") + .build(); + } - @Primary - @Bean(name = "requestTransactionManager") - public PlatformTransactionManager transactionManager( - @Qualifier("requestEntityManagerFactory") EntityManagerFactory - entityManagerFactory - ) { - return new JpaTransactionManager(entityManagerFactory); - } + @Primary + @Bean(name = "requestTransactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) { + return new JpaTransactionManager(entityManagerFactory); + } } diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java index 02922db007..fe2bd0bb98 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java @@ -21,11 +21,7 @@ package org.onap.so.adapters.vfc.rest; import static org.junit.Assert.*; - - - import javax.ws.rs.core.Response; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.vfc.MSOVfcApplication; @@ -45,28 +41,27 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = MSOVfcApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class HealthCheckHandlerTest { - - @LocalServerPort - private int port; - TestRestTemplate restTemplate = new TestRestTemplate(); + @LocalServerPort + private int port; + + TestRestTemplate restTemplate = new TestRestTemplate(); + + HttpHeaders headers = new HttpHeaders(); + + + @Test + public void testHealthcheck() throws JSONException { - HttpHeaders headers = new HttpHeaders(); + HttpEntity<String> entity = new HttpEntity<String>(null, headers); - - @Test - public void testHealthcheck() throws JSONException { + ResponseEntity<String> response = + restTemplate.exchange(createURLWithPort("manage/health"), HttpMethod.GET, entity, String.class); - HttpEntity<String> entity = new HttpEntity<String>(null, headers); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + } - ResponseEntity<String> response = restTemplate.exchange( - createURLWithPort("manage/health"), - HttpMethod.GET, entity, String.class); - - assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); - } - - private String createURLWithPort(String uri) { - return "http://localhost:" + port + uri; - } + private String createURLWithPort(String uri) { + return "http://localhost:" + port + uri; + } } diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java index 22e6def28d..08fe6187ea 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java @@ -36,7 +36,6 @@ import org.onap.so.adapters.vfc.util.RestfulUtil; import org.onap.so.db.request.beans.ResourceOperationStatus; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.springframework.http.HttpStatus; - import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @@ -122,12 +121,12 @@ public class VfcManagerTest { RestfulResponse restfulResponse = new RestfulResponse(); restfulResponse.setStatus(HttpStatus.OK.value()); - restfulResponse - .setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\", " + "\"responseDescriptor\" : {}}"); + restfulResponse.setResponseContent( + "{\"" + CommonConstant.JOB_ID + "\": \"someJobId\", " + "\"responseDescriptor\" : {}}"); when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); when(resourceOperationStatusRepository.findOne(any())) - .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus)); + .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus)); RestfulResponse response = vfcManager.getNsProgress(nsOperationKey, "someJobId"); assertEquals(HttpStatus.OK.value(), response.getStatus()); @@ -148,7 +147,7 @@ public class VfcManagerTest { when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); when(resourceOperationStatusRepository.findOne(any())) - .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus)); + .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus)); RestfulResponse response = vfcManager.scaleNs("someNsInstanceId", segInput); assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); |