From 89ff5a7f1a560bff0ac319fd7725e08c130fb9cf Mon Sep 17 00:00:00 2001 From: Sumapriya Date: Fri, 16 Mar 2018 13:25:22 +0530 Subject: Adding Junit Adding Junit for: 1.CreateVnfNotification.java 2.MsoRequest.java 3.RollbackVnfNotification.java 4.UpdateVnfNotification.java 5.VnfRollback.java 6.DeleteVnfNotification.java 7.ObjectFactory.java 8.QueryVnfNotification.java Sonar Link: https://sonar.onap.org/code?id=org.onap.so%3Aso&selected=org.onap.so%3AMSOCommonBPMN%3Asrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fmso%2Fbpmn%2Fcommon%2Fadapter%2Fvnf Change-Id: I7cc60cb10984d58f50bd40033d48e224de4efbd7 Issue-ID: SO-490 Signed-off-by: Sumapriya --- .../adapter/vnf/CreateVnfNotificationTest.java | 61 ++++++++++++++++++++++ .../adapter/vnf/DeleteVnfNotificationTest.java | 43 +++++++++++++++ .../bpmn/common/adapter/vnf/MsoRequestTest.java | 37 +++++++++++++ .../bpmn/common/adapter/vnf/ObjectFactoryTest.java | 58 ++++++++++++++++++++ .../adapter/vnf/QueryVnfNotificationTest.java | 60 +++++++++++++++++++++ .../adapter/vnf/RollbackVnfNotificationTest.java | 43 +++++++++++++++ .../adapter/vnf/UpdateVnfNotificationTest.java | 59 +++++++++++++++++++++ .../bpmn/common/adapter/vnf/VnfRollbackTest.java | 48 +++++++++++++++++ 8 files changed, 409 insertions(+) create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotificationTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotificationTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequestTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactoryTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotificationTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotificationTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotificationTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollbackTest.java (limited to 'bpmn/MSOCommonBPMN/src') diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotificationTest.java new file mode 100644 index 0000000000..18a2108c86 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotificationTest.java @@ -0,0 +1,61 @@ +/* +* ============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.bpmn.common.adapter.vnf; + +import static org.junit.Assert.*; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs; +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs.Entry; + +public class CreateVnfNotificationTest { + + @Test + public void test() { + CreateVnfNotification cvn=new CreateVnfNotification(); + Entry ent = new Entry(); + MsoExceptionCategory exception = MsoExceptionCategory.OPENSTACK; + Outputs value=new Outputs(); + VnfRollback vnf=new VnfRollback(); + vnf.setCloudSiteId("cloud"); + cvn.setCompleted(true); + cvn.setErrorMessage("emsg"); + cvn.setException(exception); + cvn.setMessageId("id"); + cvn.setOutputs(value); + ent.setKey("key"); + ent.setValue("value"); + cvn.setRollback(vnf); + cvn.setVnfId("vnf"); + assertTrue(cvn.isCompleted()); + assert(cvn.getErrorMessage().equals("emsg")); + assert(cvn.getException()).equals(exception); + assert(cvn.getMessageId()).equals("id"); + assert(cvn.getRollback()).equals(vnf); + assert(cvn.getOutputs()).equals(value); + assert(cvn.getVnfId()).equals("vnf"); + assert(ent.getKey()).equals("key"); + assert(ent.getValue()).equals("value"); + assert(ent.toString()!=null); + assert(cvn.toString()!=null); + assert(vnf.getCloudSiteId().equals("cloud")); + assert(value.getEntry()!=null); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotificationTest.java new file mode 100644 index 0000000000..10e760e8de --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotificationTest.java @@ -0,0 +1,43 @@ +/* +* ============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.bpmn.common.adapter.vnf; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DeleteVnfNotificationTest { + + @Test + public void test() { + DeleteVnfNotification dvn=new DeleteVnfNotification(); + MsoExceptionCategory exception = MsoExceptionCategory.OPENSTACK; + dvn.setCompleted(true); + dvn.setErrorMessage("msg"); + dvn.setMessageId("id"); + dvn.setException(exception); + assert(dvn.getErrorMessage().equals("msg")); + assert(dvn.getMessageId().equals("id")); + assert(dvn.getException().equals(exception)); + assert(dvn.toString()!=null); + assertTrue(dvn.isCompleted()); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequestTest.java new file mode 100644 index 0000000000..59aff8cf77 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequestTest.java @@ -0,0 +1,37 @@ +/* +* ============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.bpmn.common.adapter.vnf; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class MsoRequestTest { + private MsoRequest msorequest = new MsoRequest(); + @Test + public void testMsoRequest() { + msorequest.setRequestId("requestId"); + msorequest.setServiceInstanceId("serviceInstanceId"); + assertEquals(msorequest.getRequestId(), "requestId"); + assertEquals(msorequest.getServiceInstanceId(), "serviceInstanceId"); + } + @Test + public void testtoString() { + assert(msorequest.toString())!= null; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactoryTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactoryTest.java new file mode 100644 index 0000000000..77ba0ea59b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactoryTest.java @@ -0,0 +1,58 @@ +/* +* ============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.bpmn.common.adapter.vnf; + +import static org.mockito.Mockito.mock; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs; + +public class ObjectFactoryTest { + private ObjectFactory ofa=new ObjectFactory(); + + @Test + public void test() { + CreateVnfNotification cvn=mock( CreateVnfNotification.class); + UpdateVnfNotification uvn=mock (UpdateVnfNotification.class); + QueryVnfNotification qn=mock(QueryVnfNotification.class); + DeleteVnfNotification dvn=mock( DeleteVnfNotification.class); + RollbackVnfNotification rvn=mock( RollbackVnfNotification.class); + MsoRequest mr=mock( MsoRequest.class); + Outputs opt=mock(Outputs.class); + ofa.createCreateVnfNotification(); + ofa.createCreateVnfNotificationOutputs(); + ofa.createDeleteVnfNotification(); + ofa.createQueryVnfNotification(); + ofa.createUpdateVnfNotification(); + ofa.createMsoRequest(); + ofa.createRollbackVnfNotification(); + ofa.createUpdateVnfNotificationOutputs(); + ofa.createQueryVnfNotificationOutputs(); + ofa.createVnfRollback(); + ofa.createUpdateVnfNotificationOutputsEntry(); + ofa.createQueryVnfNotificationOutputsEntry(); + ofa.createCreateVnfNotificationOutputsEntry(); + ofa.createCreateVnfNotification(cvn); + ofa.createDeleteVnfNotification(dvn); + ofa.createQueryVnfNotification(qn); + ofa.createRollbackVnfNotification(rvn); + ofa.createUpdateVnfNotification(uvn); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotificationTest.java new file mode 100644 index 0000000000..59e10baedc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotificationTest.java @@ -0,0 +1,60 @@ +/* +* ============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.bpmn.common.adapter.vnf; + +import static org.junit.Assert.*; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs; +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs.Entry; + +public class QueryVnfNotificationTest { + private QueryVnfNotification qvn=new QueryVnfNotification(); + + @Test + public void test() { + Entry ent = new Entry(); + MsoExceptionCategory exception = MsoExceptionCategory.OPENSTACK; + Outputs opt=new Outputs(); + VnfStatus vnf=VnfStatus.ACTIVE; + qvn.setCompleted(true); + qvn.setErrorMessage("error"); + qvn.setException(exception); + qvn.setMessageId("id"); + qvn.setStatus(vnf); + qvn.setVnfId("id"); + qvn.setVnfExists(true); + ent.setKey("key"); + ent.setValue("value"); + assert(qvn.getErrorMessage().equals("error")); + assert(qvn.getException()).equals(exception); + assert(qvn.getMessageId()).equals("id"); + assert(qvn.getStatus()).equals(vnf); + assert(qvn.getVnfId()).equals("id"); + assertTrue(qvn.isVnfExists()); + assertTrue(qvn.isCompleted()); + assert(opt.getEntry()!=null); + assert(opt.toString()!=null); + assert(ent.getValue()).equals("value"); + assert(ent.getKey()).equals("key"); + assert(ent.toString()!=null); + assert(qvn.toString()!=null); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotificationTest.java new file mode 100644 index 0000000000..c6602d33f9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotificationTest.java @@ -0,0 +1,43 @@ +/*- + * ============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.bpmn.common.adapter.vnf; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class RollbackVnfNotificationTest { + private RollbackVnfNotification rvn = new RollbackVnfNotification(); + MsoExceptionCategory mso= MsoExceptionCategory.OPENSTACK; + @Test + public void testRollbackVnfNotification() { + rvn.setMessageId("messageId"); + rvn.setCompleted(true); + rvn.setException(mso); + rvn.setErrorMessage("errorMessage"); + assertEquals(rvn.getMessageId(), "messageId"); + assertEquals(rvn.isCompleted(), true); + assertEquals(rvn.getException(), mso); + assertEquals(rvn.getErrorMessage(), "errorMessage"); + } + @Test + public void testtoString() { + assert(rvn.toString()!=null); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotificationTest.java new file mode 100644 index 0000000000..825695b3dd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotificationTest.java @@ -0,0 +1,59 @@ +/* +* ============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.bpmn.common.adapter.vnf; + +import static org.junit.Assert.*; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs; +import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs.Entry; + +public class UpdateVnfNotificationTest { + private UpdateVnfNotification updatevnf = new UpdateVnfNotification(); + MsoExceptionCategory mso; + Outputs value= new Outputs(); + VnfRollback roll = new VnfRollback(); + private Entry entry = new Entry(); + + @Test + public void testUpdateVnfNotification() { + updatevnf.setMessageId("messageId"); + updatevnf.setCompleted(true); + updatevnf.setException(mso); + updatevnf.setErrorMessage("errorMessage"); + updatevnf.setOutputs(value); + updatevnf.setRollback(roll); + entry.setKey("key"); + entry.setValue("value"); + assertEquals(updatevnf.getMessageId(), "messageId"); + assertEquals(updatevnf.isCompleted(), true); + assertEquals(updatevnf.getException(), mso); + assertEquals(updatevnf.getErrorMessage(), "errorMessage"); + assertEquals(updatevnf.getOutputs(), value); + assertEquals(updatevnf.getRollback(), roll); + assertEquals(entry.getKey(), "key"); + assertEquals(entry.getValue(), "value"); + } + @Test + public void testtoString() { + assert(updatevnf.toString()!= null); + assert(entry.toString()!= null); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollbackTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollbackTest.java new file mode 100644 index 0000000000..ebed8714df --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollbackTest.java @@ -0,0 +1,48 @@ +/* +* ============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.bpmn.common.adapter.vnf; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class VnfRollbackTest { + private VnfRollback vnfrollback = new VnfRollback(); + MsoRequest mso = new MsoRequest(); + @Test + public void testVnfRollback() { + vnfrollback.setCloudSiteId("cloudSiteId"); + vnfrollback.setMsoRequest(mso); + vnfrollback.setTenantCreated(true); + vnfrollback.setTenantId("tenantId"); + vnfrollback.setVnfCreated(true); + vnfrollback.setVnfId("vnfId"); + assertEquals(vnfrollback.getCloudSiteId(), "cloudSiteId"); + assertEquals(vnfrollback.getMsoRequest(), mso); + assertEquals(vnfrollback.isTenantCreated(), true); + assertEquals(vnfrollback.getTenantId(), "tenantId"); + assertEquals(vnfrollback.isVnfCreated(), true); + assertEquals(vnfrollback.getVnfId(), "vnfId"); + } + @Test + public void testtoString() { + assert(vnfrollback.toString() != null); + } +} -- cgit 1.2.3-korg