diff options
Diffstat (limited to 'catalog-model/src/test/java')
12 files changed, 393 insertions, 144 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/config/CatalogModelSpringConfigTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/config/CatalogModelSpringConfigTest.java new file mode 100644 index 0000000000..3e9b4ea2e4 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/config/CatalogModelSpringConfigTest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.config; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.openecomp.sdc.be.model.tosca.validators.DataTypeValidatorConverter; + +public class CatalogModelSpringConfigTest { + + @Test + public void shouldReturnDataTypeValidatorConverter() { + DataTypeValidatorConverter dataTypeValidatorConverter = new CatalogModelSpringConfig() + .dataTypeValidatorConverter(); + assertNotNull(dataTypeValidatorConverter); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ConsumerDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ConsumerDefinitionTest.java new file mode 100644 index 0000000000..86ed903df6 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ConsumerDefinitionTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 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.sdc.be.model; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition; + +public class ConsumerDefinitionTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(ConsumerDataDefinition.class, + hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty", "type", "version")); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/SchemaTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/SchemaTest.java new file mode 100644 index 0000000000..e0a44b1078 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/SchemaTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.model; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; + +public class SchemaTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(Schema.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadNodeFilterPropertyInfoTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadNodeFilterPropertyInfoTest.java new file mode 100644 index 0000000000..363005167e --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadNodeFilterPropertyInfoTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.model; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; + +public class UploadNodeFilterPropertyInfoTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(UploadNodeFilterPropertyInfo.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadPropInfoTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadPropInfoTest.java index bec936a52e..942b80cc7c 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadPropInfoTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadPropInfoTest.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. @@ -17,106 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.model; -import java.util.List; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; -import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; - public class UploadPropInfoTest { - - private UploadPropInfo createTestSubject() { - return new UploadPropInfo(); - } - - - @Test - public void testGetGet_input() throws Exception { - UploadPropInfo testSubject; - List<GetInputValueDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getGet_input(); - } - - - @Test - public void testSetGet_input() throws Exception { - UploadPropInfo testSubject; - List<GetInputValueDataDefinition> get_input = null; - - // default test - testSubject = createTestSubject(); - testSubject.setGet_input(get_input); - } - - - @Test - public void testGetValue() throws Exception { - UploadPropInfo testSubject; - Object result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getValue(); - } - - @Test - public void testSetValue() throws Exception { - UploadPropInfo testSubject; - Object value = null; - - // default test - testSubject = createTestSubject(); - testSubject.setValue(value); - } - - - @Test - public void testGetDescription() throws Exception { - UploadPropInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - UploadPropInfo testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } - - - @Test - public void testIsPassword() throws Exception { - UploadPropInfo testSubject; - boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isPassword(); - } - - - @Test - public void testSetPassword() throws Exception { - UploadPropInfo testSubject; - boolean password = false; - - // default test - testSubject = createTestSubject(); - testSubject.setPassword(password); + public void shouldHaveValidGettersAndSetters() { + assertThat(UploadPropInfo.class, hasValidGettersAndSetters()); } -} +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java index 6dc8cd681c..8ce7d8db57 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java @@ -17,59 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.model; -import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.Test; public class UploadReqInfoTest { - private UploadReqInfo createTestSubject() { - return new UploadReqInfo(); - } - - - @Test - public void testGetCapabilityName() throws Exception { - UploadReqInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilityName(); - } - - @Test - public void testSetCapabilityName() throws Exception { - UploadReqInfo testSubject; - String capabilityName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilityName(capabilityName); - } - - - @Test - public void testGetNode() throws Exception { - UploadReqInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNode(); - } - - - @Test - public void testSetNode() throws Exception { - UploadReqInfo testSubject; - String node = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setNode(node); + public void shouldHaveValidGettersAndSetters() { + assertThat(UploadReqInfo.class, hasValidGettersAndSetters()); } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadataTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadataTest.java new file mode 100644 index 0000000000..bcbdbfa0c8 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadataTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.model.normatives; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class ToscaTypeMetadataTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(ToscaTypeMetadata.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/ComponentUtilitiesTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/ComponentUtilitiesTest.java new file mode 100644 index 0000000000..46f09f754d --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/ComponentUtilitiesTest.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.model.utils; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.datatypes.elements.Annotation; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.InputDefinition; + +@RunWith(MockitoJUnitRunner.class) +public class ComponentUtilitiesTest { + + @Mock + private Component component; + @Mock + private ComponentInstance componentInstance; + private Optional<ComponentInstance> optionalComponentInstance; + + @Before + public void setUp() throws Exception { + optionalComponentInstance = Optional.of(componentInstance); + } + + @Test + public void shouldGetComponentInstanceNameByInstanceId() { + Mockito.when(component.getComponentInstanceById("1")).thenReturn(optionalComponentInstance); + Mockito.when(component.getComponentInstanceByName("1")).thenReturn(optionalComponentInstance); + Mockito.when(componentInstance.getName()).thenReturn("1"); + Optional<String> componentInstanceNameByInstanceId = ComponentUtilities + .getComponentInstanceNameByInstanceId(component, "1"); + assertEquals(componentInstanceNameByInstanceId.orElse(null), "1"); + } + + @Test + public void shouldGetInputByName() { + List<InputDefinition> inputs = new ArrayList<>(); + PropertyDataDefinition prop = new PropertyDataDefinition(); + prop.setName("test"); + InputDefinition input = new InputDefinition(prop); + List<Annotation> annotations = new ArrayList<>(); + Annotation annotation = new Annotation(); + annotation.setName("annotation"); + annotations.add(annotation); + input.setAnnotationsToInput(annotations); + inputs.add(input); + Mockito.when(component.safeGetInputs()).thenReturn(inputs); + List<Annotation> result = ComponentUtilities.getInputAnnotations(component, "test"); + assertEquals(result.get(0), annotation); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/GroupUtilsTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/GroupUtilsTest.java new file mode 100644 index 0000000000..599d5a2b86 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/GroupUtilsTest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.model.utils; + +import static org.junit.Assert.*; +import static org.openecomp.sdc.common.api.Constants.DEFAULT_GROUP_VF_MODULE; +import static org.openecomp.sdc.common.api.Constants.GROUP_TOSCA_HEAT; + +import org.junit.Test; + +public class GroupUtilsTest { + + @Test + public void shouldBeVfModule() { + boolean vfModule = GroupUtils.isVfModule(DEFAULT_GROUP_VF_MODULE); + assertTrue(vfModule); + } + + @Test + public void shouldNotBeVfModule() { + boolean vfModule = GroupUtils.isVfModule(GROUP_TOSCA_HEAT); + assertFalse(vfModule); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UIConstraintTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UIConstraintTest.java new file mode 100644 index 0000000000..e95fc85833 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UIConstraintTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.ui.model; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; + +public class UIConstraintTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(UIConstraint.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UINodeFilterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UINodeFilterTest.java new file mode 100644 index 0000000000..8f767fe418 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UINodeFilterTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.ui.model; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; + +public class UINodeFilterTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(UINodeFilter.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UiCombinationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UiCombinationTest.java new file mode 100644 index 0000000000..3bce3fd779 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/ui/model/UiCombinationTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.sdc.be.ui.model; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; + +public class UiCombinationTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(UiCombination.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file |