diff options
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src/test/java/org')
21 files changed, 413 insertions, 2141 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestDatabaseTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/TestApplication.java index a26f417634..ec2c41bf8c 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestDatabaseTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/TestApplication.java @@ -7,9 +7,9 @@ * 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. @@ -18,23 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.requestsdb;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class RequestDatabaseTest {
-
- @Test
- public void testCheckVnfIdStatus() {
- RequestsDatabase reqDb = mock(RequestsDatabase.class);
- when(reqDb.checkVnfIdStatus(any(String.class))).thenReturn(new InfraActiveRequests());
-
- InfraActiveRequests response = reqDb.checkVnfIdStatus("123456");
- assertNotNull(response);
- }
-}
+package org.onap.so; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Profile; + +@SpringBootApplication(scanBasePackages = { "org.onap" }) +@Profile("test") +public class TestApplication { + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationStatusTest.java new file mode 100644 index 0000000000..a10d948b8f --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationStatusTest.java @@ -0,0 +1,82 @@ +/*- + * ============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.db.request; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.Date; + +import javax.transaction.Transactional; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.TestApplication; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.OperationStatusId; +import org.onap.so.db.request.data.repository.OperationStatusRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class OperationStatusTest { + + @Autowired + private OperationStatusRepository repository; + + @Test + @Transactional + public void timeStampCreated() throws InterruptedException { + + final String testServiceId = "test-service-id"; + final String testOperationId = "test-operation-id"; + final OperationStatusId id = new OperationStatusId(testServiceId, testOperationId); + OperationStatus status = new OperationStatus(); + + status.setServiceId(testServiceId); + status.setOperationId(testOperationId); + + status = repository.saveAndFlush(status); + + OperationStatus found = repository.findOne(id); + + Date operateAt = found.getOperateAt(); + assertNotNull(operateAt); + assertEquals(testServiceId, found.getServiceId()); + Date finishedAt = found.getFinishedAt(); + status.setProgress("test-progress"); + //timestamps only set to save on 1 second changes + Thread.sleep(1000); + repository.saveAndFlush(status); + + OperationStatus foundUpdate = repository.findOne(id); + + assertEquals(operateAt.toString(), foundUpdate.getOperateAt().toString()); + assertNotNull(foundUpdate.getFinishedAt()); + assertNotEquals(finishedAt.toString(), foundUpdate.getFinishedAt().toString()); + assertEquals("test-progress", foundUpdate.getProgress()); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java new file mode 100644 index 0000000000..c12d3cbb7b --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java @@ -0,0 +1,80 @@ +/*- + * ============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.db.request; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.TestApplication; +import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; +import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.ExampleMatcher; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class OperationalEnvServiceModelStatusTest { + + @Autowired + private OperationalEnvServiceModelStatusRepository repository; + + + @Test + public void updateWithoutAllKeys() throws Exception { + + OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus(); + status.setRequestId("request-id-1"); + status.setOperationalEnvId("oper-env-id-1"); + status.setServiceModelVersionId("service-model-ver-id-1"); + status.setRetryCount(0); + + repository.saveAndFlush(status); + OperationalEnvServiceModelStatus status2 = repository.findOneByOperationalEnvIdAndServiceModelVersionId("oper-env-id-1", "service-model-ver-id-1"); + status2.setRetryCount(1); + + repository.saveAndFlush(status2); + + OperationalEnvServiceModelStatus status3 = new OperationalEnvServiceModelStatus(); + + status3.setRequestId("request-id-2"); + status3.setOperationalEnvId("oper-env-id-1"); + status3.setServiceModelVersionId("service-model-ver-id-2"); + status3.setRetryCount(2); + + repository.saveAndFlush(status3); + + OperationalEnvServiceModelStatus exampleObj = new OperationalEnvServiceModelStatus(); + exampleObj.setOperationalEnvId("oper-env-id-1"); + exampleObj.setServiceModelVersionId("service-model-ver-id-1"); + ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("requestId"); + OperationalEnvServiceModelStatus foundStatus = repository.findOne(Example.of(exampleObj,matcher)); + if(foundStatus== null) + throw new Exception("No status found"); + + assertEquals(new Integer(1), foundStatus.getRetryCount()); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/RequestDBConfig.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/RequestDBConfig.java new file mode 100644 index 0000000000..9bcff13699 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/RequestDBConfig.java @@ -0,0 +1,77 @@ +/*- + * ============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.db.request; + + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories( + entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", + basePackages = { "org.onap.so.db.request.data.repository" } + ) +public class RequestDBConfig { + + @Primary + @Bean(name = "requestDataSource") + @ConfigurationProperties(prefix = "spring.datasource") + public DataSource dataSource() { + return DataSourceBuilder.create().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); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/SiteStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/SiteStatusTest.java new file mode 100644 index 0000000000..917f52d4ad --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/SiteStatusTest.java @@ -0,0 +1,86 @@ +/*- + * ============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.db.request; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.transaction.Transactional; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.TestApplication; +import org.onap.so.db.request.beans.SiteStatus; +import org.onap.so.db.request.data.repository.SiteStatusRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class SiteStatusTest { + + @Autowired + private SiteStatusRepository repository; + + @Test + @Transactional + public void timeStampCreated() throws InterruptedException { + SiteStatus found = repository.findOne("test name4"); + assertNotNull(found.getCreated()); + assertEquals("test name4", found.getSiteName()); + } + + @Test + public void sortByCreated() { + + final PageRequest page1 = new PageRequest( + 0, 20, Direction.DESC, "created" + ); + + SiteStatus example = new SiteStatus(); + example.setStatus(true); + Page<SiteStatus> found = repository.findAll(Example.of(example), page1); + + assertEquals("test name4", found.getContent().get(0).getSiteName()); + + } + + @Test + public void updateStatus() { + + SiteStatus status = repository.findOne("test name update"); + status.setStatus(false); + + repository.saveAndFlush(status); + + assertEquals(false, repository.findOne("test name update").getStatus()); + + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/beans/BeansTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/beans/BeansTest.java new file mode 100644 index 0000000000..3f9443ff4a --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/beans/BeansTest.java @@ -0,0 +1,71 @@ +/*- + * ============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.db.request.beans; + +import static org.onap.so.openpojo.rules.HasAnnotationMatcher.hasAnnotation; + +import javax.persistence.Temporal; + +import org.junit.Test; +import org.onap.so.openpojo.rules.CustomSetterMustExistRule; +import org.onap.so.openpojo.rules.EqualsAndHashCodeTester; +import org.onap.so.openpojo.rules.HasEqualsAndHashCodeRule; +import org.onap.so.openpojo.rules.HasToStringRule; +import org.onap.so.openpojo.rules.ToStringTester; + +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.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class BeansTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.db.request.beans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new CustomSetterMustExistRule().exclude(hasAnnotation(Temporal.class))) + .with(new HasEqualsAndHashCodeRule()) + .with(new HasToStringRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .with(new EqualsAndHashCodeTester()) + .with(new ToStringTester()) + .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterEnum()); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsTest.java deleted file mode 100644 index 33f1fbbb76..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.*; - -import java.sql.Timestamp; - -import org.junit.Test; - -public class InfraRequestsTest { - - InfraRequests ir=new InfraRequests(); - InfraRequests ir1=new InfraRequests("requestId", "action"); - Timestamp time=new Timestamp(123); - long progress=111; - @Test - public void test() { - ir.setAaiServiceId("aaiServiceId"); - ir.setAction("action"); - ir.setAicCloudRegion("aicCloudRegion"); - ir.setAicNodeClli("aicNodeClli"); - ir.setCallBackUrl("callBackUrl"); - ir.setClientRequestId("clientRequestId"); - ir.setConfigurationId("configurationId"); - ir.setConfigurationName("configurationName"); - ir.setCorrelator("correlator"); - ir.setEndTime(time); - ir.setLastModifiedBy("lastModifiedBy"); - ir.setModifyTime(time); - ir.setNetworkId("networkId"); - ir.setNetworkName("networkName"); - ir.setNetworkType("networkType"); - ir.setOperationalEnvId("operationalEnvId"); - ir.setOperationalEnvName("operationalEnvName"); - ir.setProgress(progress); - ir.setProvStatus("provStatus"); - ir.setRequestAction("requestAction"); - ir.setRequestBody("requestBody"); - ir.setRequestId("requestId"); - ir.setRequestorId("requestorId"); - ir.setRequestScope("requestScope"); - ir.setRequestStatus("requestStatus"); - ir.setRequestType("requestType"); - ir.setResponseBody("responseBody"); - ir.setServiceInstanceId("serviceInstanceId"); - ir.setServiceInstanceName("serviceInstanceName"); - ir.setServiceType("serviceType"); - ir.setSource("source"); - ir.setStartTime(time); - ir.setStatusMessage("statusMessage"); - ir.setTenantId("tenantId"); - ir.setVfModuleId("vfModuleId"); - ir.setVfModuleModelName("vfModuleModelName"); - ir.setVfModuleName("vfModuleName"); - ir.setVnfId("vnfId"); - ir.setVnfName("vnfName"); - ir.setVnfOutputs("vnfOutputs"); - ir.setVnfParams("vnfParams"); - ir.setVnfType("vnfType"); - ir.setVolumeGroupId("volumeGroupId"); - ir.setVolumeGroupName("volumeGroupName"); - - assertEquals(ir.getAaiServiceId(), "aaiServiceId"); - assertEquals(ir.getAction(),"action"); - assertEquals(ir.getAicCloudRegion(),"aicCloudRegion"); - assertEquals(ir.getAicNodeClli(),"aicNodeClli"); - assertEquals(ir.getCallBackUrl(),"callBackUrl"); - assertEquals(ir.getClientRequestId(),"clientRequestId"); - assertEquals(ir.getConfigurationId(),"configurationId"); - assertEquals(ir.getConfigurationName(),"configurationName"); - assertEquals(ir.getCorrelator(),"correlator"); - assertEquals(ir.getEndTime(),time); - assertEquals(ir.getLastModifiedBy(),"lastModifiedBy"); - assertEquals(ir.getModifyTime(),time); - assertEquals(ir.getNetworkId(),"networkId"); - assertEquals(ir.getNetworkName(),"networkName"); - assertEquals(ir.getNetworkType(),"networkType"); - assertEquals(ir.getOperationalEnvId(),"operationalEnvId"); - assertEquals(ir.getOperationalEnvName(),"operationalEnvName"); - assert(ir.getProgress().equals(progress)); - assertEquals(ir.getProvStatus(),"provStatus"); - assertEquals(ir.getRequestAction(),"requestAction"); - assertEquals(ir.getRequestBody(),"requestBody"); - assertEquals(ir.getRequestId(),"requestId"); - assertEquals(ir.getRequestorId(),"requestorId"); - assertEquals(ir.getRequestScope(),"requestScope"); - assertEquals(ir.getRequestStatus(),"requestStatus"); - assertEquals(ir.getRequestType(),"requestType"); - assertEquals(ir.getResponseBody(),"responseBody"); - assertEquals(ir.getServiceInstanceId(),"serviceInstanceId"); - assertEquals(ir.getServiceInstanceName(),"serviceInstanceName"); - assertEquals(ir.getServiceType(),"serviceType"); - assertEquals(ir.getSource(),"source"); - assertEquals(ir.getStartTime(),time); - assertEquals(ir.getStatusMessage(),"statusMessage"); - assertEquals(ir.getTenantId(),"tenantId"); - assertEquals(ir.getVfModuleId(),"vfModuleId"); - assertEquals(ir.getVfModuleModelName(),"vfModuleModelName"); - assertEquals(ir.getVfModuleName(),"vfModuleName"); - assertEquals(ir.getVnfId(),"vnfId"); - assertEquals(ir.getVnfName(),"vnfName"); - assertEquals(ir.getVnfOutputs(),"vnfOutputs"); - assertEquals(ir.getVnfParams(),"vnfParams"); - assertEquals(ir.getVnfType(),"vnfType"); - assertEquals(ir.getVolumeGroupId(),"volumeGroupId"); - assertEquals(ir.getVolumeGroupName(),"volumeGroupName"); - - } - - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationStatusTest.java deleted file mode 100644 index cf18524ee1..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationStatusTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.*; -import java.sql.Timestamp; -import org.junit.Test; - -public class OperationStatusTest { - - OperationStatus os=new OperationStatus(); - Timestamp time=new Timestamp(10); - Object obj=new Object(); - @Test - public void test() { - os.setFinishedAt(time); - os.setOperateAt(time); - os.setOperation("operation"); - os.setOperationContent("operationContent"); - os.setOperationId("operationId"); - os.setProgress("progress"); - os.setReason("reason"); - os.setResult("result"); - os.setServiceId("serviceId"); - os.setServiceName("serviceName"); - os.setUserId("userId"); - - assertEquals(os.getFinishedAt(), time); - assertEquals(os.getOperateAt(), time); - assertEquals(os.getOperation(), "operation"); - assertEquals(os.getOperationContent(), "operationContent"); - assertEquals(os.getOperationId(), "operationId"); - assertEquals(os.getProgress(), "progress"); - assertEquals(os.getReason(), "reason"); - assertEquals(os.getResult(), "result"); - assertEquals(os.getServiceId(), "serviceId"); - assertEquals(os.getServiceName(), "serviceName"); - assertEquals(os.getUserId(), "userId"); - - os.equals(obj); - os.hashCode(); - } - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java deleted file mode 100644 index 89213f9948..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDbTest.java +++ /dev/null @@ -1,112 +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.requestsdb; - - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Arrays; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.db.AbstractSessionFactoryManager; - - -public class OperationalEnvDistributionStatusDbTest { - @Mock - private AbstractSessionFactoryManager sessionFactoryRequest; - @Mock - private SessionFactory sessionFactory; - @Mock - private Session session; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(sessionFactory.openSession()).thenReturn(session); - when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory); - - } - - @Test - public void insertFailure() { - OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - omsDB.insertOperationalEnvDistributionStatus("myDistId", "myEnvId", "myModelVerId", "myDistIdStatus", "myReqId"); - } - - @Test - public void updateFailureRetryCount() { - OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - omsDB.updateOperationalEnvDistributionStatus("asdcStatus", "myDistId", "myEnvId", "myVerId"); - } - - @Test - public void getOperationalEnvIdStatusTest() { - OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - OperationalEnvDistributionStatus status = new OperationalEnvDistributionStatus(); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(status); - when(session.isOpen()).thenReturn(true); - assertEquals(status, omsDB.getOperationalEnvDistributionStatusPerReqId("myDistId", "myReqId")); - } - - @Test - public void getOperationalEnvServiceModelStatusTest() { - OperationalEnvDistributionStatusDb omsDB = new OperationalEnvDistributionStatusDb(this.sessionFactoryRequest); - OperationalEnvDistributionStatus status = new OperationalEnvDistributionStatus(); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(status); - when(session.isOpen()).thenReturn(true); - assertEquals(status, omsDB.getOperationalEnvDistributionStatus("myDistId")); - } -}
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusTest.java deleted file mode 100644 index 6381ec63b9..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - - -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import java.sql.Timestamp; - -public class OperationalEnvDistributionStatusTest { - - OperationalEnvDistributionStatus oeds=new OperationalEnvDistributionStatus(); - Timestamp time=new Timestamp(10); - @Test - public void test(){ - oeds.setCreateTime(time); - oeds.setDistributionId("distributionId"); - oeds.setDistributionIdErrorReason("distributionIdErrorReason"); - oeds.setDistributionIdStatus("distributionIdStatus"); - oeds.setModifyTime(time); - oeds.setOperationalEnvId("operationalEnvId"); - oeds.setRequestId("requestId"); - oeds.setServiceModelVersionId("serviceModelVersionId"); - - assertEquals(oeds.getCreateTime(), time); - assertEquals(oeds.getDistributionId(), "distributionId"); - assertEquals(oeds.getDistributionIdErrorReason(), "distributionIdErrorReason"); - assertEquals(oeds.getDistributionIdStatus(), "distributionIdStatus"); - assertEquals(oeds.getModifyTime(),time); - assertEquals(oeds.getOperationalEnvId(), "operationalEnvId"); - assertEquals(oeds.getRequestId(), "requestId"); - assertEquals(oeds.getServiceModelVersionId(), "serviceModelVersionId"); - } -} - - /*protected String _distributionId; - protected String _operationalEnvId; - protected String _serviceModelVersionId; - protected String _requestId; - protected String _distributionIdStatus; - protected String _distributionIdErrorReason; - protected Timestamp _createTime; - protected Timestamp _modifyTime; - - public OperationalEnvDistributionStatusTest() { - } - - @Before - public void setUp() { - _operationalEnvDistributionStatus = mock(OperationalEnvDistributionStatus.class); - _distributionId = "12abad84e7ff"; - _operationalEnvId = "28122015552391"; - _serviceModelVersionId = "28122015552391-aa"; - _requestId = "1234"; - _distributionIdStatus = "SENT"; - _distributionIdErrorReason = "Fail"; - _createTime = new Timestamp (System.currentTimeMillis()); - _modifyTime = new Timestamp (System.currentTimeMillis()); - - when(_operationalEnvDistributionStatus.getDistributionId()).thenReturn(_distributionId); - when(_operationalEnvDistributionStatus.getOperationalEnvId()).thenReturn(_operationalEnvId); - when(_operationalEnvDistributionStatus.getServiceModelVersionId()).thenReturn(_serviceModelVersionId); - when(_operationalEnvDistributionStatus.getRequestId()).thenReturn(_requestId); - when(_operationalEnvDistributionStatus.getDistributionIdStatus()).thenReturn(_distributionIdStatus); - when(_operationalEnvDistributionStatus.getDistributionIdErrorReason()).thenReturn(_distributionIdErrorReason); - when(_operationalEnvDistributionStatus.getCreateTime()).thenReturn(_createTime); - when(_operationalEnvDistributionStatus.getModifyTime()).thenReturn(_modifyTime); - } - - - @After - public void tearDown() { - _operationalEnvDistributionStatus = null; - } - - *//** - * Test of getDistributionId method - *//* - @Test - public void testGetDistributionId() { - _operationalEnvDistributionStatus.setDistributionId(_distributionId); - assertEquals(_operationalEnvDistributionStatus.getDistributionId(),_distributionId); - - } - - *//** - * Test setDistributionId method - *//* - @Test - public void testSetDistributionId() { - _operationalEnvDistributionStatus.setDistributionId(_distributionId); - verify(_operationalEnvDistributionStatus).setDistributionId(_distributionId); - } - - *//** - * Test of getOperationalEnvId method - *//* - @Test - public void testGetOperationalEnvId() { - _operationalEnvDistributionStatus.setOperationalEnvId(_operationalEnvId); - assertEquals(_operationalEnvDistributionStatus.getOperationalEnvId(),_operationalEnvId); - - } - - *//** - * Test setOperationalEnvId method - *//* - @Test - public void testSetOperationalEnvId() { - _operationalEnvDistributionStatus.setOperationalEnvId(_operationalEnvId); - verify(_operationalEnvDistributionStatus).setOperationalEnvId(_operationalEnvId); - } - - *//** - * Test of getServiceModelVersionId method - *//* - @Test - public void testGetServiceModelVersionId() { - _operationalEnvDistributionStatus.setServiceModelVersionId(_serviceModelVersionId); - assertEquals(_operationalEnvDistributionStatus.getServiceModelVersionId(),_serviceModelVersionId); - - } - - *//** - * Test setServiceModelVersionId method - *//* - @Test - public void testSetServiceModelVersionId() { - _operationalEnvDistributionStatus.setServiceModelVersionId(_serviceModelVersionId); - verify(_operationalEnvDistributionStatus).setServiceModelVersionId(_serviceModelVersionId); - } - - *//** - * Test of getRequestId method - *//* - @Test - public void testGetRequestId() { - _operationalEnvDistributionStatus.setRequestId(_requestId); - assertEquals(_operationalEnvDistributionStatus.getRequestId(),_requestId); - - } - - *//** - * Test setRequestId method - *//* - @Test - public void testSetRequestId() { - _operationalEnvDistributionStatus.setRequestId(_requestId); - verify(_operationalEnvDistributionStatus).setRequestId(_requestId); - } - - *//** - * Test of getDistributionIdStatus method - *//* - @Test - public void testGetDistributionIdStatus() { - _operationalEnvDistributionStatus.setDistributionIdStatus(_distributionIdStatus); - assertEquals(_operationalEnvDistributionStatus.getDistributionIdStatus(),_distributionIdStatus); - - } - - *//** - * Test setDistributionIdStatus method - *//* - @Test - public void testSetDistributionIdStatus() { - _operationalEnvDistributionStatus.setDistributionIdStatus(_distributionIdStatus); - verify(_operationalEnvDistributionStatus).setDistributionIdStatus(_distributionIdStatus); - } - - *//** - * Test of getDistributionIdErrorReason method - *//* - @Test - public void testGetDistributionIdErrorReason() { - _operationalEnvDistributionStatus.setDistributionIdErrorReason(_distributionIdErrorReason); - assertEquals(_operationalEnvDistributionStatus.getDistributionIdErrorReason(),_distributionIdErrorReason); - - } - - *//** - * Test setDistributionIdErrorReason method - *//* - @Test - public void testSetDistributionIdErrorReason() { - _operationalEnvDistributionStatus.setDistributionIdErrorReason(_distributionIdErrorReason); - verify(_operationalEnvDistributionStatus).setDistributionIdErrorReason(_distributionIdErrorReason); - } - - *//** - * Test of getCreateTime method - *//* - @Test - public void testGetCreateTime() { - _operationalEnvDistributionStatus.setCreateTime(_createTime); - System.out.println("CreateTime : " + _createTime); - assertEquals(_operationalEnvDistributionStatus.getCreateTime(),_createTime); - - } - - *//** - * Test setCreateTime method - *//* - @Test - public void testSetCreateTime() { - _operationalEnvDistributionStatus.setCreateTime(_createTime); - verify(_operationalEnvDistributionStatus).setCreateTime(_createTime); - } - - *//** - * Test of getModifyTime method - *//* - @Test - public void testGetModifyTime() { - _operationalEnvDistributionStatus.setModifyTime(_modifyTime); - System.out.println("ModifyTime : " + _modifyTime); - assertEquals(_operationalEnvDistributionStatus.getModifyTime(),_modifyTime); - - } - - *//** - * Test setModifyTime method - *//* - @Test - public void testSetModifyTime() { - _operationalEnvDistributionStatus.setModifyTime(_modifyTime); - verify(_operationalEnvDistributionStatus).setModifyTime(_modifyTime); - } - - -} -*/
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java deleted file mode 100644 index fb2a5a44d2..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDbTest.java +++ /dev/null @@ -1,120 +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.requestsdb; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Arrays; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.db.AbstractSessionFactoryManager; - -public class OperationalEnvServiceModelStatusDbTest { - - @Mock - private AbstractSessionFactoryManager sessionFactoryRequest; - @Mock - private SessionFactory sessionFactory; - @Mock - private Session session; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(sessionFactory.openSession()).thenReturn(session); - when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory); - - } - - @Test - public void insertFailure() { - OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - omsDB.insertOperationalEnvServiceModelStatus("myRequestId", "myOperationalEnvId", "myServiceModelVersionId", "myVal", "myRecoveryAction", 1, "myWorkloadContext"); - } - - @Test - public void updateFailureRetryCount() { - OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - omsDB.updateOperationalEnvRetryCountStatus("myOperationalEnvId", "myServiceModelVersionId", "status", 1); - } - - @Test - public void updateFailureRetryCountPerReqId() { - OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - omsDB.updateOperationalEnvRetryCountStatusPerReqId("myOperationalEnvId", "myServiceModelVersionId", "status", 1, "myReqId"); - } - - - @Test - public void getOperationalEnvIdStatusTest() { - OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus(); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.list()).thenReturn(Arrays.asList(status)); - when(session.isOpen()).thenReturn(true); - assertEquals(status, omsDB.getOperationalEnvIdStatus("myEnvId", "myReqId").get(0)); - } - - @Test - public void getOperationalEnvServiceModelStatusTest() { - OperationalEnvServiceModelStatusDb omsDB = new OperationalEnvServiceModelStatusDb(this.sessionFactoryRequest); - OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus(); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(status); - when(session.isOpen()).thenReturn(true); - assertEquals(status, omsDB.getOperationalEnvServiceModelStatus("myEnvId", "myModelId")); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusTest.java deleted file mode 100644 index ecde7b36f6..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusTest.java +++ /dev/null @@ -1,271 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.assertEquals; -import java.sql.Timestamp; -import org.junit.Test; - -public class OperationalEnvServiceModelStatusTest { - - OperationalEnvServiceModelStatus oesms=new OperationalEnvServiceModelStatus(); - Timestamp time=new Timestamp(10); - @Test - public void test(){ - oesms.setCreateTime(time); - oesms.setModifyTime(time); - oesms.setOperationalEnvId("operationalEnvId"); - oesms.setRecoveryAction("recoveryAction"); - oesms.setRequestId("requestId"); - oesms.setRetryCount(0); - oesms.setServiceModelVersionDistrStatus("serviceModelVersionDistrStatus"); - oesms.setServiceModelVersionId("serviceModelVersionId"); - oesms.setWorkloadContext("workloadContext"); - - assertEquals(oesms.getCreateTime(), time); - assertEquals(oesms.getModifyTime(), time); - assertEquals(oesms.getOperationalEnvId(), "operationalEnvId"); - assertEquals(oesms.getRecoveryAction(), "recoveryAction"); - assertEquals(oesms.getRequestId(), "requestId"); - assertEquals(oesms.getRetryCount(), 0); - assertEquals(oesms.getServiceModelVersionDistrStatus(), "serviceModelVersionDistrStatus"); - assertEquals(oesms.getServiceModelVersionId(), "serviceModelVersionId"); - assertEquals(oesms.getWorkloadContext(), "workloadContext"); - } -} - /*OperationalEnvServiceModelStatus _operationalEnvServiceModelStatus; - - protected String _requestId; - protected String _operationalEnvId; - protected String _serviceModelVersionId; - protected String _serviceModelVersionDistrStatus; - protected String _recoveryAction; - private int _retryCount; - private String _workloadContext; - protected Timestamp _createTime; - protected Timestamp _modifyTime; - - - public OperationalEnvServiceModelStatusTest() { - } - - @Before - public void setUp() { - _operationalEnvServiceModelStatus = mock(OperationalEnvServiceModelStatus.class); - _requestId = "1234"; - _operationalEnvId = "28122015552391"; - _serviceModelVersionId = "28122015552391-aa"; - _serviceModelVersionDistrStatus = "SENT"; - _recoveryAction = "Retry"; - _retryCount = 0; - _workloadContext = "VNF_E2E-IST"; - _createTime = new Timestamp (System.currentTimeMillis()); - _modifyTime = new Timestamp (System.currentTimeMillis()); - - when(_operationalEnvServiceModelStatus.getRequestId()).thenReturn(_requestId); - when(_operationalEnvServiceModelStatus.getOperationalEnvId()).thenReturn(_operationalEnvId); - when(_operationalEnvServiceModelStatus.getServiceModelVersionId()).thenReturn(_serviceModelVersionId); - when(_operationalEnvServiceModelStatus.getServiceModelVersionDistrStatus()).thenReturn(_serviceModelVersionDistrStatus); - when(_operationalEnvServiceModelStatus.getRecoveryAction()).thenReturn(_recoveryAction); - when(_operationalEnvServiceModelStatus.getRetryCount()).thenReturn(_retryCount); - when(_operationalEnvServiceModelStatus.getWorkloadContext()).thenReturn(_workloadContext); - when(_operationalEnvServiceModelStatus.getCreateTime()).thenReturn(_createTime); - when(_operationalEnvServiceModelStatus.getModifyTime()).thenReturn(_modifyTime); - } - - - @After - public void tearDown() { - _operationalEnvServiceModelStatus = null; - } - - *//** - * Test of getRequestId method - *//* - @Test - public void testGetRequestId() { - _operationalEnvServiceModelStatus.setRequestId(_requestId); - assertEquals(_operationalEnvServiceModelStatus.getRequestId(),_requestId); - - } - - *//** - * Test setRequestId method - *//* - @Test - public void testSetRequestId() { - _operationalEnvServiceModelStatus.setRequestId(_requestId); - verify(_operationalEnvServiceModelStatus).setRequestId(_requestId); - } - - *//** - * Test of getOperationalEnvId method - *//* - @Test - public void testGetOperationalEnvId() { - _operationalEnvServiceModelStatus.setOperationalEnvId(_operationalEnvId); - assertEquals(_operationalEnvServiceModelStatus.getOperationalEnvId(),_operationalEnvId); - - } - - *//** - * Test setOperationalEnvId method - *//* - @Test - public void testSetOperationalEnvId() { - _operationalEnvServiceModelStatus.setOperationalEnvId(_operationalEnvId); - verify(_operationalEnvServiceModelStatus).setOperationalEnvId(_operationalEnvId); - } - - *//** - * Test of getServiceModelVersionId method - *//* - @Test - public void testGetServiceModelVersionId() { - _operationalEnvServiceModelStatus.setServiceModelVersionId(_serviceModelVersionId); - assertEquals(_operationalEnvServiceModelStatus.getServiceModelVersionId(),_serviceModelVersionId); - - } - - *//** - * Test setServiceModelVersionId method - *//* - @Test - public void testSetServiceModelVersionId() { - _operationalEnvServiceModelStatus.setServiceModelVersionId(_serviceModelVersionId); - verify(_operationalEnvServiceModelStatus).setServiceModelVersionId(_serviceModelVersionId); - } - - *//** - * Test of getServiceModelVersionId method - *//* - @Test - public void testGetServiceModelVersionDistrStatus() { - _operationalEnvServiceModelStatus.setServiceModelVersionDistrStatus(_serviceModelVersionDistrStatus); - assertEquals(_operationalEnvServiceModelStatus.getServiceModelVersionDistrStatus(),_serviceModelVersionDistrStatus); - - } - - *//** - * Test setServiceModelVersionId method - *//* - @Test - public void testSetServiceModelVersionDistrStatus() { - _operationalEnvServiceModelStatus.setServiceModelVersionDistrStatus(_serviceModelVersionDistrStatus); - verify(_operationalEnvServiceModelStatus).setServiceModelVersionDistrStatus(_serviceModelVersionDistrStatus); - } - - *//** - * Test of getOperationalEnvId method - *//* - @Test - public void testGetRecoveryAction() { - _operationalEnvServiceModelStatus.setRecoveryAction(_recoveryAction); - assertEquals(_operationalEnvServiceModelStatus.getRecoveryAction(),_recoveryAction); - - } - - *//** - * Test setOperationalEnvId method - *//* - @Test - public void testSetRecoveryAction() { - _operationalEnvServiceModelStatus.setRecoveryAction(_recoveryAction); - verify(_operationalEnvServiceModelStatus).setRecoveryAction(_recoveryAction); - } - - *//** - * Test of getOperationalEnvId method - *//* - @Test - public void testGetRetryCount() { - _operationalEnvServiceModelStatus.setRetryCount(_retryCount); - assertEquals(_operationalEnvServiceModelStatus.getRetryCount(),_retryCount); - - } - - *//** - * Test setOperationalEnvId method - *//* - @Test - public void testSetRetryCount() { - _operationalEnvServiceModelStatus.setRetryCount(_retryCount); - verify(_operationalEnvServiceModelStatus).setRetryCount(_retryCount); - } - - *//** - * Test of getOperationalEnvId method - *//* - @Test - public void testGetWorkloadContext() { - _operationalEnvServiceModelStatus.setWorkloadContext(_workloadContext); - assertEquals(_operationalEnvServiceModelStatus.getWorkloadContext(),_workloadContext); - - } - - *//** - * Test setOperationalEnvId method - *//* - @Test - public void testSetWorkloadContext() { - _operationalEnvServiceModelStatus.setWorkloadContext(_workloadContext); - verify(_operationalEnvServiceModelStatus).setWorkloadContext(_workloadContext); - } - - *//** - * Test of getCreateTime method - *//* - @Test - public void testGetCreateTime() { - _operationalEnvServiceModelStatus.setCreateTime(_createTime); - assertEquals(_operationalEnvServiceModelStatus.getCreateTime(),_createTime); - - } - - *//** - * Test setCreateTime method - *//* - @Test - public void testSetCreateTime() { - _operationalEnvServiceModelStatus.setCreateTime(_createTime); - verify(_operationalEnvServiceModelStatus).setCreateTime(_createTime); - } - - *//** - * Test of getModifyTime method - *//* - @Test - public void testGetModifyTime() { - _operationalEnvServiceModelStatus.setModifyTime(_modifyTime); - assertEquals(_operationalEnvServiceModelStatus.getModifyTime(),_modifyTime); - - } - - *//** - * Test setModifyTime method - *//* - @Test - public void testSetModifyTime() { - _operationalEnvServiceModelStatus.setModifyTime(_modifyTime); - verify(_operationalEnvServiceModelStatus).setModifyTime(_modifyTime); - } - */ - diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java deleted file mode 100644 index aacdd96420..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java +++ /dev/null @@ -1,287 +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.requestsdb; - - -import mockit.Expectations; -import mockit.Mocked; -import mockit.integration.junit4.JMockit; -import org.hibernate.Criteria; -import org.hibernate.Query; -import org.hibernate.SQLQuery; -import org.hibernate.Session; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.openecomp.mso.db.AbstractSessionFactoryManager; - -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -@RunWith(JMockit.class) -public class RequestsDatabaseTest { - - RequestsDatabase requestsDatabase = RequestsDatabase.getInstance(); - - @Test - public void getInstanceTest() throws Exception { - RequestsDatabase instance = RequestsDatabase.getInstance(); - assertEquals(RequestsDatabase.class, instance.getClass()); - } - - @Test - public void healthCheckTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked SQLQuery query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createSQLQuery(" show tables "); result = query; - query.list(); result = Arrays.asList("table1", "table2"); - }}; - - assertTrue(requestsDatabase.healthCheck()); - } - - @Test - public void updateInfraStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - query.executeUpdate(); result = 1; - }}; - assertEquals(1, requestsDatabase.updateInfraStatus("123", "unknown", "unknown")); - } - - @Test - public void updateInfraStatus1Test(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - query.executeUpdate(); result = 1; - }}; - assertEquals(1, requestsDatabase.updateInfraStatus("123", "unknown", 0, "unknown")); - } - - @Test - public void updateInfraFinalStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - query.executeUpdate(); result = 1; - }}; - assertEquals(1, requestsDatabase.updateInfraFinalStatus("123", - "unknown", - "statusMessage", - 0, - "responsebody", - "lastmodifiedby")); - } - - @Test - public void getRequestFromInfraActiveTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - query.uniqueResult(); result = new InfraActiveRequests("123", "action"); - }}; - assertEquals("123", - requestsDatabase.getRequestFromInfraActive("123").getRequestId()); - } - - @Test - public void getOrchestrationFiltersFromInfraActiveTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Criteria criteria) throws Exception { - - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createCriteria(InfraActiveRequests.class); result = criteria; - criteria.list(); result = Arrays.asList(new InfraActiveRequests("123", "action")); - }}; - assertEquals(1, - requestsDatabase.getRequestListFromInfraActive("queryattr", - "queryvalue", - "type").size()); - } - - @Test - public void getRequestListFromInfraActiveTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType"); result = query; - query.uniqueResult(); result = new InfraActiveRequests("123", "action"); - }}; - assertEquals("123", - requestsDatabase.getRequestFromInfraActive("123", "requestType").getRequestId()); - } - - @Test - public void getRequestFromInfraActive1Test(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Criteria criteria) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createCriteria(InfraActiveRequests.class); result = criteria; - criteria.list(); result = Arrays.asList(new InfraActiveRequests()); - }}; - assertEquals(1, - requestsDatabase.getRequestListFromInfraActive("queryAttr", - "queryvalue", - "type").size()); - } - - @Test - @Ignore // 1802 merge - public void checkDuplicateByVnfNameTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); result = query; - query.list(); result = Arrays.asList(new InfraActiveRequests("123", "action")); - }}; - assertEquals("123", - requestsDatabase.checkDuplicateByVnfName("vnfname", - "action", - "requesttype").getRequestId()); - } - - @Test - @Ignore // 1802 merge - public void checkDuplicateByVnfIdTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); result = query; - query.list(); result = Arrays.asList(new InfraActiveRequests("123", "action")); - }}; - assertEquals("123", - requestsDatabase.checkDuplicateByVnfId("vnfname", - "action", - "requesttype").getRequestId()); - } - - @Test - public void setMockDBTest() throws Exception { - requestsDatabase.setMockDB(null); - } - - @Test - public void getSiteStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM SiteStatus WHERE siteName = :site_name"); result = query; - query.uniqueResult(); result = new SiteStatus(); - }}; - assertEquals(SiteStatus.class, - requestsDatabase.getSiteStatus("site").getClass()); - } - - @Test - public void updateSiteStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM SiteStatus WHERE siteName = :site_name"); result = query; - query.uniqueResult(); result = new SiteStatus(); - }}; - requestsDatabase.updateSiteStatus("site", true); - } - - @Test - public void getOperationStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id"); result = query; - query.uniqueResult(); result = new OperationStatus(); - }}; - assertEquals(OperationStatus.class, - requestsDatabase.getOperationStatus("123", - "Unknown").getClass()); - } - - @Test - public void getOperationStatusByServiceIdTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id order by OPERATE_AT desc"); result = query; - List<Object>list = query.list(); result = new OperationStatus(); - }}; - assertEquals(OperationStatus.class, - requestsDatabase.getOperationStatusByServiceId("123").getClass()); - } - - @Test - public void getOperationStatusByServiceNameTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM OperationStatus WHERE SERVICE_NAME = :service_name"); result = query; - query.uniqueResult(); result = new OperationStatus(); - }}; - assertEquals(OperationStatus.class, - requestsDatabase.getOperationStatusByServiceName("servicename").getClass()); - } - - @Test - public void updateOperationStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id"); result = query; - query.uniqueResult(); result = new OperationStatus(); - }}; - requestsDatabase.updateOperationStatus(new OperationStatus()); - } - - @Test - public void getResourceOperationStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session, - @Mocked Query query) throws Exception { - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - session.createQuery("FROM ResourceOperationStatus WHERE serviceId = :service_id and operationId = :operation_id and resourceTemplateUUID= :uuid"); result = query; - query.uniqueResult(); result = new ResourceOperationStatus(); - }}; - assertEquals(ResourceOperationStatus.class, - requestsDatabase.getResourceOperationStatus("serviceId", - "operationid", - "123-uuid").getClass()); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/ResourceOperationStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/ResourceOperationStatusTest.java deleted file mode 100644 index a9773c3bae..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/ResourceOperationStatusTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ResourceOperationStatusTest { - - ResourceOperationStatus ros=new ResourceOperationStatus(); - ResourceOperationStatus ros1=new ResourceOperationStatus("serviceId", "operationId", "resourceTemplateUUID"); - Object obj=new Object(); - @Test - public void test() { - ros.setErrorCode("errorCode"); - ros.setJobId("jobId"); - ros.setOperationId("operationId"); - ros.setOperType("operType"); - ros.setProgress("progress"); - ros.setResourceInstanceID("resourceInstanceID"); - ros.setResourceTemplateUUID("resourceTemplateUUId"); - ros.setServiceId("serviceId"); - ros.setStatus("101"); - ros.setStatusDescription("statusDescription"); - - assertEquals(ros.getErrorCode(), "errorCode"); - assertEquals(ros.getJobId(), "jobId"); - assertEquals(ros.getOperationId(), "operationId"); - assertEquals(ros.getOperType(), "operType"); - assertEquals(ros.getProgress(), "progress"); - assertEquals(ros.getResourceInstanceID(), "resourceInstanceID"); - assertEquals(ros.getResourceTemplateUUID(), "resourceTemplateUUId"); - assertEquals(ros.getServiceId(), "serviceId"); - assertEquals(ros.getStatus(), "101"); - assertEquals(ros.getStatusDescription(), "statusDescription"); - ros.equals(obj); - ros.hashCode(); - } - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusTest.java deleted file mode 100644 index b989dac262..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.*; -import java.sql.Timestamp; -import org.junit.Test; - -public class SiteStatusTest { - - SiteStatus ss=new SiteStatus(); - Timestamp time=new Timestamp(10); - @Test - public void test() { - ss.setCreated(time); - ss.setSiteName("siteName"); - ss.setStatus(true); - - assertEquals(ss.getCreated(), time); - assertEquals(ss.getSiteName(), "siteName"); - assertEquals(ss.getStatus(), true); - } - @Test - public void testToString(){ - assert(ss.toString()!=null); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java deleted file mode 100644 index a86812e167..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDbTest.java +++ /dev/null @@ -1,127 +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.requestsdb; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Arrays; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.db.AbstractSessionFactoryManager; - - -public class WatchdogComponentDistributionStatusDbTest { - - @Mock - private AbstractSessionFactoryManager sessionFactoryRequest; - @Mock - private SessionFactory sessionFactory; - @Mock - private Session session; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(sessionFactory.openSession()).thenReturn(session); - when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory); - - } - - @Test - public void insertFailure() { - WatchdogComponentDistributionStatusDb wds = new WatchdogComponentDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - wds.insertWatchdogComponentDistributionStatus("myId", "myComponentName", "myStatus"); - } - - - @Test - public void getWatchdogComponentNamesTest() { - WatchdogComponentDistributionStatusDb wds = new WatchdogComponentDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.list()).thenReturn(Arrays.asList("myValue")); - when(session.isOpen()).thenReturn(true); - assertEquals("myValue", wds.getWatchdogComponentNames("myId").get(0)); - } - - @Test - public void getWatchdogComponentDistributionStatusTest() { - WatchdogComponentDistributionStatusDb wds = new WatchdogComponentDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.list()).thenReturn(Arrays.asList("myValue")); - when(session.isOpen()).thenReturn(true); - assertEquals("myValue", wds.getWatchdogComponentDistributionStatus("myStatus").get(0)); - assertEquals("myValue", wds.getWatchdogComponentDistributionStatus("myId", "myName").get(0)); - } - - @Test - public void testGetWatchdogDistributionIdNotFound() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - assertEquals(null, wds.getWatchdogDistributionId("test")); - } - - @Test - public void testGetWatchdogDistributionIdStatus() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn("myValue"); - when(session.isOpen()).thenReturn(true); - assertEquals("myValue", wds.getWatchdogDistributionIdStatus("test")); - } - - @Test - public void testGetWatchdogDistributionIdStatusNotFound() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - assertEquals(null, wds.getWatchdogDistributionIdStatus("test")); - } - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusTest.java deleted file mode 100644 index 0d68c12a0a..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.assertEquals; -import java.sql.Timestamp; -import org.junit.Test; - -public class WatchdogComponentDistributionStatusTest { - - WatchdogComponentDistributionStatus wcds=new WatchdogComponentDistributionStatus(); - Timestamp time=new Timestamp(10); - - @Test - public void test(){ - wcds.setComponentDistributionStatus("componentDistributionStatus"); - wcds.setComponentName("componentName"); - wcds.setCreateTime(time); - wcds.setDistributionId("distributionId"); - wcds.setModifyTime(time); - - assertEquals(wcds.getComponentDistributionStatus(), "componentDistributionStatus"); - assertEquals(wcds.getComponentName(), "componentName"); - assertEquals(wcds.getCreateTime(), time); - assertEquals(wcds.getDistributionId(), "distributionId"); - assertEquals(wcds.getModifyTime(), time); - } -} - - /*WatchdogComponentDistributionStatus _watchdogComponentDistributionStatus; - - protected String _distributionId; - protected String _componentName; - protected String _componentDistributionStatus; - protected Timestamp _createTime; - protected Timestamp _modifyTime; - - public WatchdogComponentDistributionStatusTest() { - } - - @Before - public void setUp() { - _watchdogComponentDistributionStatus = mock(WatchdogComponentDistributionStatus.class); - _distributionId = "12abad84e7ff"; - _componentName = "MSO"; - _componentDistributionStatus = "SENT"; - _createTime = new Timestamp (System.currentTimeMillis()); - _modifyTime = new Timestamp (System.currentTimeMillis()); - - when(_watchdogComponentDistributionStatus.getDistributionId()).thenReturn(_distributionId); - when(_watchdogComponentDistributionStatus.getComponentName()).thenReturn(_componentName); - when(_watchdogComponentDistributionStatus.getComponentDistributionStatus()).thenReturn(_componentDistributionStatus); - when(_watchdogComponentDistributionStatus.getCreateTime()).thenReturn(_createTime); - when(_watchdogComponentDistributionStatus.getModifyTime()).thenReturn(_modifyTime); - } - - @After - public void tearDown() { - _watchdogComponentDistributionStatus = null; - } - - *//** - * Test of getDistributionId method - *//* - @Test - public void testGetDistributionId() { - _watchdogComponentDistributionStatus.setDistributionId(_distributionId); - assertEquals(_watchdogComponentDistributionStatus.getDistributionId(),_distributionId); - - } - - *//** - * Test setDistributionId method - *//* - @Test - public void testSetDistributionId() { - _watchdogComponentDistributionStatus.setDistributionId(_distributionId); - verify(_watchdogComponentDistributionStatus).setDistributionId(_distributionId); - } - - *//** - * Test of getDistributionId method - *//* - @Test - public void testGetComponentName() { - _watchdogComponentDistributionStatus.setComponentName(_componentName); - assertEquals(_watchdogComponentDistributionStatus.getComponentName(),_componentName); - - } - - *//** - * Test setDistributionId method - *//* - @Test - public void testSetComponentName() { - _watchdogComponentDistributionStatus.setComponentName(_componentName); - verify(_watchdogComponentDistributionStatus).setComponentName(_componentName); - } - - *//** - * Test of getDistributionId method - *//* - @Test - public void testGetComponentDistributionStatus() { - _watchdogComponentDistributionStatus.setComponentDistributionStatus(_componentDistributionStatus); - assertEquals(_watchdogComponentDistributionStatus.getComponentDistributionStatus(),_componentDistributionStatus); - - } - - *//** - * Test setDistributionId method - *//* - @Test - public void testSetComponentDistributionStatus() { - _watchdogComponentDistributionStatus.setComponentDistributionStatus(_componentDistributionStatus); - verify(_watchdogComponentDistributionStatus).setComponentDistributionStatus(_componentDistributionStatus); - } - - *//** - * Test of getCreateTime method - *//* - @Test - public void testGetCreateTime() { - _watchdogComponentDistributionStatus.setCreateTime(_createTime); - System.out.println("CreateTime : " + _createTime); - assertEquals(_watchdogComponentDistributionStatus.getCreateTime(),_createTime); - - } - - *//** - * Test setCreateTime method - *//* - @Test - public void testSetCreateTime() { - _watchdogComponentDistributionStatus.setCreateTime(_createTime); - verify(_watchdogComponentDistributionStatus).setCreateTime(_createTime); - } - - *//** - * Test of getModifyTime method - *//* - @Test - public void testGetModifyTime() { - _watchdogComponentDistributionStatus.setModifyTime(_modifyTime); - System.out.println("ModifyTime : " + _modifyTime); - assertEquals(_watchdogComponentDistributionStatus.getModifyTime(),_modifyTime); - - } - - *//** - * Test setModifyTime method - *//* - @Test - public void testSetModifyTime() { - _watchdogComponentDistributionStatus.setModifyTime(_modifyTime); - verify(_watchdogComponentDistributionStatus).setModifyTime(_modifyTime); - } - -} -*/
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java deleted file mode 100644 index 3371018605..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDbTest.java +++ /dev/null @@ -1,124 +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.requestsdb; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.db.AbstractSessionFactoryManager; - -public class WatchdogDistributionStatusDbTest { - - @Mock - private AbstractSessionFactoryManager sessionFactoryRequest; - @Mock - private SessionFactory sessionFactory; - @Mock - private Session session; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(sessionFactory.openSession()).thenReturn(session); - when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory); - - } - - @Test - public void insertFailure() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - wds.insertWatchdogDistributionId("myId"); - } - - @Test - public void updateFailure() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - wds.updateWatchdogDistributionIdStatus("myId", "myStatus"); - } - - @Test - public void testGetWatchdogDistributionId() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn("myValue"); - when(session.isOpen()).thenReturn(true); - assertEquals("myValue", wds.getWatchdogDistributionId("test")); - } - - @Test - public void testGetWatchdogDistributionIdNotFound() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - assertEquals(null, wds.getWatchdogDistributionId("test")); - } - - @Test - public void testGetWatchdogDistributionIdStatus() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn("myValue"); - when(session.isOpen()).thenReturn(true); - assertEquals("myValue", wds.getWatchdogDistributionIdStatus("test")); - } - - @Test - public void testGetWatchdogDistributionIdStatusNotFound() { - WatchdogDistributionStatusDb wds = new WatchdogDistributionStatusDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - assertEquals(null, wds.getWatchdogDistributionIdStatus("test")); - } - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusTest.java deleted file mode 100644 index c10d7ae15b..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.assertEquals; -import java.sql.Timestamp; -import org.junit.Test; - -public class WatchdogDistributionStatusTest { - - WatchdogDistributionStatus wds=new WatchdogDistributionStatus(); - Timestamp time=new Timestamp(10); - @Test - public void test() { - wds.setCreateTime(time); - wds.setDistributionId("distributionId"); - wds.setDistributionIdStatus("distributionIdStatus"); - wds.setModifyTime(time); - - assertEquals(wds.getCreateTime(), time); - assertEquals(wds.getDistributionId(), "distributionId"); - assertEquals(wds.getDistributionIdStatus(), "distributionIdStatus"); - assertEquals(wds.getModifyTime(), time); - - } - - -/* WatchdogDistributionStatus _watchdogDistributionStatus; - - protected String _distributionId; - protected String _distributionIdStatus; - protected Timestamp _createTime; - protected Timestamp _modifyTime; - - public WatchdogDistributionStatusTest() { - } - - @Before - public void setUp() { - _watchdogDistributionStatus = mock(WatchdogDistributionStatus.class); - _distributionId = "12abad84e7ff"; - _distributionIdStatus = "SENT"; - _createTime = new Timestamp (System.currentTimeMillis()); - _modifyTime = new Timestamp (System.currentTimeMillis()); - - when(_watchdogDistributionStatus.getDistributionId()).thenReturn(_distributionId); - when(_watchdogDistributionStatus.getDistributionIdStatus()).thenReturn(_distributionIdStatus); - when(_watchdogDistributionStatus.getCreateTime()).thenReturn(_createTime); - when(_watchdogDistributionStatus.getModifyTime()).thenReturn(_modifyTime); - } - - @After - public void tearDown() { - _watchdogDistributionStatus = null; - } - - *//** - * Test of getDistributionId method - *//* - @Test - public void testGetDistributionId() { - _watchdogDistributionStatus.setDistributionId(_distributionId); - assertEquals(_watchdogDistributionStatus.getDistributionId(),_distributionId); - - } - - *//** - * Test setDistributionId method - *//* - @Test - public void testSetDistributionId() { - _watchdogDistributionStatus.setDistributionId(_distributionId); - verify(_watchdogDistributionStatus).setDistributionId(_distributionId); - } - - *//** - * Test of getDistributionIdStatus method - *//* - @Test - public void testGetComponentDistributionStatus() { - _watchdogDistributionStatus.setDistributionIdStatus(_distributionIdStatus); - assertEquals(_watchdogDistributionStatus.getDistributionIdStatus(),_distributionIdStatus); - - } - - *//** - * Test setDistributionIdStatus method - *//* - @Test - public void testSetComponentDistributionStatus() { - _watchdogDistributionStatus.setDistributionIdStatus(_distributionIdStatus); - verify(_watchdogDistributionStatus).setDistributionIdStatus(_distributionIdStatus); - } - - *//** - * Test of getCreateTime method - *//* - @Test - public void testGetCreateTime() { - _watchdogDistributionStatus.setCreateTime(_createTime); - assertEquals(_watchdogDistributionStatus.getCreateTime(),_createTime); - - } - - *//** - * Test setCreateTime method - *//* - @Test - public void testSetCreateTime() { - _watchdogDistributionStatus.setCreateTime(_createTime); - verify(_watchdogDistributionStatus).setCreateTime(_createTime); - } - - *//** - * Test of getModifyTime method - *//* - @Test - public void testGetModifyTime() { - _watchdogDistributionStatus.setModifyTime(_modifyTime); - assertEquals(_watchdogDistributionStatus.getModifyTime(),_modifyTime); - - } - - *//** - * Test setModifyTime method - *//* - @Test - public void testSetModifyTime() { - _watchdogDistributionStatus.setModifyTime(_modifyTime); - verify(_watchdogDistributionStatus).setModifyTime(_modifyTime); - }*/ -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java deleted file mode 100644 index 42224b0238..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDbTest.java +++ /dev/null @@ -1,86 +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.requestsdb; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.db.AbstractSessionFactoryManager; - - -public class WatchdogServiceModVerIdLookupDbTest { - @Mock - private AbstractSessionFactoryManager sessionFactoryRequest; - @Mock - private SessionFactory sessionFactory; - @Mock - private Session session; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(sessionFactory.openSession()).thenReturn(session); - when(sessionFactoryRequest.getSessionFactory()).thenReturn(sessionFactory); - - } - - @Test - public void getWatchdogServiceModVerIdTest() { - WatchdogServiceModVerIdLookupDb wds = new WatchdogServiceModVerIdLookupDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - assertEquals(null, wds.getWatchdogServiceModVerId("test")); - } - - @Test - public void insertWatchdogServiceModVerIdLookupTest() { - WatchdogServiceModVerIdLookupDb wds = new WatchdogServiceModVerIdLookupDb(this.sessionFactoryRequest); - Query mockQuery = mock(Query.class); - when(session.createQuery(any(String.class))).thenReturn(mockQuery); - when(mockQuery.uniqueResult()).thenReturn(null); - when(session.isOpen()).thenReturn(true); - when(session.getTransaction()).thenThrow(Exception.class); - thrown.expect(Exception.class); - - wds.insertWatchdogServiceModVerIdLookup("myId", "myModelVersion"); - } - - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupTest.java deleted file mode 100644 index d27c1b817e..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 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.openecomp.mso.requestsdb; - -import static org.junit.Assert.assertEquals; -import java.sql.Timestamp; -import org.junit.Test; - -public class WatchdogServiceModVerIdLookupTest { - - WatchdogServiceModVerIdLookup wsmil=new WatchdogServiceModVerIdLookup(); - Timestamp time=new Timestamp(10); - @Test - public void test(){ - wsmil.setCreateTime(time); - wsmil.setDistributionId("distributionId"); - wsmil.setServiceModelVersionId("serviceModelVersionId"); - - assertEquals(wsmil.getCreateTime(),time); - assertEquals(wsmil.getDistributionId(), "distributionId"); - assertEquals(wsmil.getServiceModelVersionId(), "serviceModelVersionId"); - } -} -/*WatchdogServiceModVerIdLookup _watchdogServiceModVerIdLookup; - - protected String _distributionId; - protected String _serviceModelVersionId; - protected Timestamp _createTime; - - public WatchdogServiceModVerIdLookupTest() { - } - - @Before - public void setUp() { - _watchdogServiceModVerIdLookup = mock(WatchdogServiceModVerIdLookup.class); - _serviceModelVersionId = "12abad84e7ff"; - _createTime = new Timestamp (System.currentTimeMillis()); - - when(_watchdogServiceModVerIdLookup.getDistributionId()).thenReturn(_distributionId); - when(_watchdogServiceModVerIdLookup.getServiceModelVersionId()).thenReturn(_serviceModelVersionId); - when(_watchdogServiceModVerIdLookup.getCreateTime()).thenReturn(_createTime); - } - - @After - public void tearDown() { - _watchdogServiceModVerIdLookup = null; - } - - *//** - * Test of getDistributionId method - *//* - @Test - public void testGetDistributionId() { - _watchdogServiceModVerIdLookup.setDistributionId(_distributionId); - assertEquals(_watchdogServiceModVerIdLookup.getDistributionId(),_distributionId); - - } - - *//** - * Test setDistributionId method - *//* - @Test - public void testSetDistributionId() { - _watchdogServiceModVerIdLookup.setDistributionId(_distributionId); - verify(_watchdogServiceModVerIdLookup).setDistributionId(_distributionId); - } - - *//** - * Test of getServiceModelVersionId method - *//* - @Test - public void testGetServiceModelVersionId() { - _watchdogServiceModVerIdLookup.setServiceModelVersionId(_serviceModelVersionId); - assertEquals(_watchdogServiceModVerIdLookup.getServiceModelVersionId(),_serviceModelVersionId); - - } - - *//** - * Test setServiceModelVersionId method - *//* - @Test - public void testSetServiceModelVersionId() { - _watchdogServiceModVerIdLookup.setServiceModelVersionId(_serviceModelVersionId); - verify(_watchdogServiceModVerIdLookup).setServiceModelVersionId(_serviceModelVersionId); - } - - *//** - * Test of getCreateTime method - *//* - @Test - public void testGetCreateTime() { - _watchdogServiceModVerIdLookup.setCreateTime(_createTime); - assertEquals(_watchdogServiceModVerIdLookup.getCreateTime(),_createTime); - - } - - *//** - * Test setCreateTime method - *//* - @Test - public void testSetCreateTime() { - _watchdogServiceModVerIdLookup.setCreateTime(_createTime); - verify(_watchdogServiceModVerIdLookup).setCreateTime(_createTime); - } - -}*/
\ No newline at end of file |