aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2019-05-14 11:03:19 +0300
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-05-14 12:00:48 +0000
commite4f211d69d65a28b665eb307b89408208a536c8b (patch)
tree5ce88ce8c4d5f02d946d246dae483514b87efe0f
parent8f9a8df44dc8d45abae56df406748aab0ef64729 (diff)
Fix test coverage
Fix test coverage for ComponentInstanceInputPropertyDeclarator.java Change-Id: Ie52b56ce07ad8eaec47166311cd8e7942b153bd0 Issue-ID: SDC-2298 Signed-off-by: talio <tali.orenbach@amdocs.com>
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java78
1 files changed, 64 insertions, 14 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java
index f5d4aabd92..258cad5ae9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/property/ComponentInstanceInputPropertyDeclaratorTest.java
@@ -1,6 +1,33 @@
+/*
+ * ============LICENSE_START=============================================================================================================
+ * Copyright (c) 2019 <Company or Individual>.
+ * ===================================================================
+ * 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.components.property;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.MockGenerator.mockComponentUtils;
+import static org.openecomp.sdc.be.MockGenerator.mockExceptionUtils;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -17,6 +44,7 @@ import org.openecomp.sdc.be.components.utils.ResourceBuilder;
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.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentParametersView;
@@ -27,18 +55,6 @@ import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.be.MockGenerator.mockComponentUtils;
-import static org.openecomp.sdc.be.MockGenerator.mockExceptionUtils;
-
@RunWith(MockitoJUnitRunner.class)
public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclaratorTestBase {
@@ -57,7 +73,9 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
@Captor
private ArgumentCaptor<ComponentParametersView> inputsFilterCaptor;
- private Annotation annotation1, annotation2;
+ private Annotation annotation1;
+
+ private Annotation annotation2;
@Override
@Before
@@ -102,6 +120,38 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
}
@Test
+ public void testCreateDeclaredProperty() {
+ ComponentInstanceInput declaredProperty = testInstance.createDeclaredProperty(prop1);
+ assertThat(declaredProperty.getUniqueId()).isEqualTo(prop1.getUniqueId());
+ }
+
+ @Test
+ public void testUpdateDeclaredProperties() {
+ List<ComponentInstanceInput> expectedProperties = Collections.singletonList(new ComponentInstanceInput(prop1));
+ Map<String, List<ComponentInstanceInput>> expectedMap = new HashMap<>();
+ expectedMap.put(prop1.getName(), expectedProperties);
+
+ when(toscaOperationFacade.addComponentInstanceInputsToComponent(eq(resource), anyMap()))
+ .thenReturn(Either.left(expectedMap));
+
+ Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> updateEither =
+ (Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus>) testInstance.updatePropertiesValues(resource, resource.getUniqueId(), expectedProperties);
+
+ assertThat(updateEither.isLeft());
+ Map<String, List<ComponentInstanceInput>> actualProperties = updateEither.left().value();
+ assertThat(actualProperties.values().size()).isEqualTo(expectedProperties.size());
+ assertThat(actualProperties.values().iterator().next()).isEqualTo(expectedProperties);
+ }
+
+ @Test
+ public void testResolvePropertiesOwner() {
+ Optional<ComponentInstance> componentInstance = testInstance.resolvePropertiesOwner(resource, INSTANCE_ID);
+
+ assertThat(componentInstance.isPresent());
+ assertThat(componentInstance.get().getUniqueId()).isEqualTo(INSTANCE_ID);
+ }
+
+ @Test
public void unDeclarePropertiesAsListInputsTest() {
InputDefinition inputToDelete = new InputDefinition();
inputToDelete.setUniqueId(INPUT_ID);
@@ -182,4 +232,4 @@ public class ComponentInstanceInputPropertyDeclaratorTest extends PropertyDeclar
.addInput(input)
.build();
}
-}
+} \ No newline at end of file