summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager
diff options
context:
space:
mode:
authorm.kowalski3 <m.kowalski3@partner.samsung.com>2019-08-08 12:07:39 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-08-26 09:04:08 +0000
commitcdd280010c3d61c34553b08e09eba5e8df6d56fc (patch)
tree416b42f27c15500b01d12d63a14671156c3351f6 /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager
parent592363fdc17ff7d0e6783204760cfbf05e630950 (diff)
Add unit test for DuplicateComputeInComponentErrorBuilder and refactor ComponentDependencyModelErrorBuilder
Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com> Change-Id: Icb6cf51f7777a8a9d3b237ecd98579edc11f9ebb
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilderTests.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilderTest.java13
4 files changed, 42 insertions, 7 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
index 12b654c413..249ad1cb28 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
@@ -38,11 +38,11 @@ public class ComponentDependencyModelErrorBuilder {
}
- public static ErrorCode getcyclicDependencyComponentErrorBuilder() {
+ public static ErrorCode getCyclicDependencyComponentErrorBuilder() {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(CYCLIC_DEPENDENCY_IN_COMPONENTS);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(CYCLIC_DEPENDENCY_COMPONENT_MSG));
+ builder.withMessage(CYCLIC_DEPENDENCY_COMPONENT_MSG);
return builder.build();
}
@@ -50,7 +50,7 @@ public class ComponentDependencyModelErrorBuilder {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(INVALID_COMPONENT_RELATION_TYPE);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(INVALID_REALTION_TYPE_MSG));
+ builder.withMessage(INVALID_REALTION_TYPE_MSG);
return builder.build();
}
@@ -58,7 +58,7 @@ public class ComponentDependencyModelErrorBuilder {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(NO_SOURCE_COMPONENT);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(NO_SOURCE_COMPONENT_MSG));
+ builder.withMessage(NO_SOURCE_COMPONENT_MSG);
return builder.build();
}
@@ -66,7 +66,7 @@ public class ComponentDependencyModelErrorBuilder {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(SAME_SOURCE_TARGET_COMPONENT);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(SOURCE_TARGET_COMPONENT_EQUAL_MSG));
+ builder.withMessage(SOURCE_TARGET_COMPONENT_EQUAL_MSG);
return builder.build();
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 59d0793eac..5d2fd518fa 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -199,7 +199,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if (validateComponentDependencies(componentDependencies)) {
vspErrors
- .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder());
+ .add(ComponentDependencyModelErrorBuilder.getCyclicDependencyComponentErrorBuilder());
}
validationResponse
.setVspErrors(vspErrors);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilderTests.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilderTests.java
index 2e471a15e8..b5dfae1ce6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilderTests.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilderTests.java
@@ -31,7 +31,7 @@ public class ComponentDependencyModelErrorBuilderTests {
@Test
public void testGetCyclicDependencyComponentErrorBuilder() {
//when
- ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder();
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getCyclicDependencyComponentErrorBuilder();
//then
assertEquals("CYCLIC_DEPENDENCY_IN_COMPONENTS", errorCode.id());
@@ -49,4 +49,26 @@ public class ComponentDependencyModelErrorBuilderTests {
assertEquals(ErrorCategory.APPLICATION, errorCode.category());
assertEquals("Invalid relation type for components.", errorCode.message());
}
+
+ @Test
+ public void testGetNoSourceComponentErrorBuilder() {
+ //when
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder();
+
+ //then
+ assertEquals("NO_SOURCE_COMPONENT", errorCode.id());
+ assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+ assertEquals("Source component is mandatory.", errorCode.message());
+ }
+
+ @Test
+ public void testGetSourceTargetComponentEqualErrorBuilder() {
+ //when
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
+
+ //then
+ assertEquals("SAME_SOURCE_TARGET_COMPONENT", errorCode.id());
+ assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+ assertEquals("Source and target components are same.", errorCode.message());
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilderTest.java
index 2f833ef444..4050ffd4a1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilderTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilderTest.java
@@ -39,4 +39,17 @@ public class DuplicateComputeInComponentErrorBuilderTest {
assertEquals("Update of attribute not allowed for VSP onboarded via HEAT.", errorCode.message());
}
+
+ @Test
+ public void testBuild() {
+ // given
+ DuplicateComputeInComponentErrorBuilder duplicateComputeInComponentErrorBuilder =
+ new DuplicateComputeInComponentErrorBuilder();
+
+ // when
+ ErrorCode errorCode = duplicateComputeInComponentErrorBuilder.build();
+
+ // then
+ assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+ }
}