summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorTomasz Golabek <tomasz.golabek@nokia.com>2019-04-08 15:04:16 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-04-10 17:03:35 +0000
commit4568e48647b15b5654a669651ddf536d590288b0 (patch)
tree55b6381738eff0b2cbc966d23012dd828d98994d /catalog-be/src/test
parent00a6a4d66b0d22d530314816b4b5697fbc975e37 (diff)
Some unit tests for catalog-be
Code coverage for some classes from catalog-be increased. Some refactor made if needed. Change-Id: I1c5a35f99fcc0ace2f7b6ba4f7ef4f41acbed5e7 Issue-ID: SDC-2220 Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java75
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java163
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java28
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java42
4 files changed, 162 insertions, 146 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java
index e39e5819d3..3b3d1f9556 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/CreateAndAssotiateInfoTest.java
@@ -1,57 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2018 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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.info;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-
public class CreateAndAssotiateInfoTest {
- private CreateAndAssotiateInfo createTestSubject() {
- return new CreateAndAssotiateInfo(new ComponentInstance(), new RequirementCapabilityRelDef());
- }
-
-
- @Test
- public void testGetNode() throws Exception {
- CreateAndAssotiateInfo testSubject;
- ComponentInstance result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNode();
- }
-
-
@Test
- public void testSetNode() throws Exception {
- CreateAndAssotiateInfo testSubject;
- ComponentInstance node = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNode(node);
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(CreateAndAssotiateInfo.class, hasValidGettersAndSetters());
}
-
@Test
- public void testGetAssociate() throws Exception {
- CreateAndAssotiateInfo testSubject;
- RequirementCapabilityRelDef result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAssociate();
+ public void shouldTestWhetherTheDefaultConstructorCorrectlySetAllFields() {
+ ComponentInstance componentInstance = new ComponentInstance();
+ RequirementCapabilityRelDef requirementCapabilityRelDef = new RequirementCapabilityRelDef();
+ CreateAndAssotiateInfo createAndAssociateInfo = new CreateAndAssotiateInfo(componentInstance, requirementCapabilityRelDef);
+ Assert.assertThat(createAndAssociateInfo.getAssociate(), is(requirementCapabilityRelDef));
+ Assert.assertThat(createAndAssociateInfo.getNode(), is(componentInstance));
}
-
- @Test
- public void testSetAssociate() throws Exception {
- CreateAndAssotiateInfo testSubject;
- RequirementCapabilityRelDef associate = null;
- // default test
- testSubject = createTestSubject();
- testSubject.setAssociate(associate);
- }
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java
index 329743f4a7..9ff004e57f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusInfoTest.java
@@ -1,122 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2018 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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.info;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Assert;
import org.junit.Test;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
import org.openecomp.sdc.common.datastructure.ESTimeBasedEvent;
-
public class DistributionStatusInfoTest {
- private DistributionStatusInfo createTestSubject() {
- return new DistributionStatusInfo(new ESTimeBasedEvent());
- }
-
-
- @Test
- public void testGetOmfComponentID() throws Exception {
- DistributionStatusInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOmfComponentID();
- }
-
-
- @Test
- public void testSetOmfComponentID() throws Exception {
- DistributionStatusInfo testSubject;
- String omfComponentID = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setOmfComponentID(omfComponentID);
- }
+ private static final String AUDIT_DISTRIBUTION_STATUS_TIME = "AUDIT_DISTRIBUTION_STATUS_TIME";
+ private static final String AUDIT_DISTRIBUTION_CONSUMER_ID = "AUDIT_DISTRIBUTION_CONSUMER_ID";
+ private static final String AUDIT_DISTRIBUTION_RESOURCE_URL = "AUDIT_DISTRIBUTION_RESOURCE_URL";
+ private static final String AUDIT_STATUS = "AUDIT_STATUS";
+ private static final String AUDIT_DESC = "AUDIT_DESC";
-
@Test
- public void testGetTimestamp() throws Exception {
- DistributionStatusInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTimestamp();
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(DistributionStatusInfo.class, hasValidGettersAndSetters());
}
-
@Test
- public void testSetTimestamp() throws Exception {
- DistributionStatusInfo testSubject;
- String timestamp = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTimestamp(timestamp);
+ public void testCtorWithESTimeBasedEvent() {
+ ESTimeBasedEvent distributionStatusEvent = createESTimeBasedEvent();
+ DistributionStatusInfo distributionStatusInfo = new DistributionStatusInfo(distributionStatusEvent);
+ Assert.assertThat(distributionStatusInfo.getTimestamp(), is(AUDIT_DISTRIBUTION_STATUS_TIME));
+ Assert.assertThat(distributionStatusInfo.getOmfComponentID(), is(AUDIT_DISTRIBUTION_CONSUMER_ID));
+ Assert.assertThat(distributionStatusInfo.getErrorReason(), is(AUDIT_DESC));
+ Assert.assertThat(distributionStatusInfo.getStatus(), is(AUDIT_STATUS));
+ Assert.assertThat(distributionStatusInfo.getUrl(), is(AUDIT_DISTRIBUTION_RESOURCE_URL));
}
-
@Test
- public void testGetUrl() throws Exception {
- DistributionStatusInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUrl();
+ public void shouldTestWhetherTheDefaultConstructorCorrectlySetAllFields() {
+ DistributionStatusInfo distributionStatusInfo = new DistributionStatusInfo(AUDIT_DISTRIBUTION_CONSUMER_ID, AUDIT_DISTRIBUTION_STATUS_TIME, AUDIT_DISTRIBUTION_RESOURCE_URL, AUDIT_STATUS);
+ Assert.assertThat(distributionStatusInfo.getUrl(), is(AUDIT_DISTRIBUTION_RESOURCE_URL));
+ Assert.assertThat(distributionStatusInfo.getStatus(), is(AUDIT_STATUS));
+ Assert.assertThat(distributionStatusInfo.getOmfComponentID(), is(AUDIT_DISTRIBUTION_CONSUMER_ID));
+ Assert.assertThat(distributionStatusInfo.getTimestamp(), is(AUDIT_DISTRIBUTION_STATUS_TIME));
}
-
- @Test
- public void testSetUrl() throws Exception {
- DistributionStatusInfo testSubject;
- String url = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setUrl(url);
+ private ESTimeBasedEvent createESTimeBasedEvent() {
+ ESTimeBasedEvent distributionStatusEvent = new ESTimeBasedEvent();
+ Map<String, Object> fields = new HashMap<>();
+ fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), AUDIT_DISTRIBUTION_CONSUMER_ID);
+ fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TIME.getDisplayName(), AUDIT_DISTRIBUTION_STATUS_TIME);
+ fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), AUDIT_DISTRIBUTION_RESOURCE_URL);
+ fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), AUDIT_STATUS);
+ fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), AUDIT_DESC);
+ distributionStatusEvent.setFields(fields);
+ return distributionStatusEvent;
}
-
- @Test
- public void testGetStatus() throws Exception {
- DistributionStatusInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getStatus();
- }
-
-
- @Test
- public void testSetStatus() throws Exception {
- DistributionStatusInfo testSubject;
- String status = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setStatus(status);
- }
-
-
- @Test
- public void testGetErrorReason() throws Exception {
- DistributionStatusInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getErrorReason();
- }
-
-
- @Test
- public void testSetErrorReason() throws Exception {
- DistributionStatusInfo testSubject;
- String errorReason = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setErrorReason(errorReason);
- }
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
index 74b8fdbdfa..fa5af8043a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
@@ -1,7 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2018 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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
+
package org.openecomp.sdc.be.info;
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -10,4 +33,9 @@ public class DistributionStatusListResponseTest {
public void shouldHaveValidGettersAndSetters() {
assertThat(DistributionStatusListResponse.class, hasValidGettersAndSetters());
}
+
+ @Test
+ public void shouldHaveValidDefaultConstructor() {
+ assertThat(DistributionStatusListResponse.class, hasValidBeanConstructor());
+ }
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
index 987db462c5..d164f009f6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
@@ -1,17 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2018 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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.info;
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-
public class DistributionStatusOfServiceInfoTest {
+ private static final String STATUS = "status";
+ private static final String USER_ID = "userID";
+ private static final String TIMESTAMP = "timestamp";
+ private static final String DISTRIBUTION_ID = "distributionID";
@Test
- public void testCtor() throws Exception {
- new DistributionStatusOfServiceInfo("","","","");
+ public void shouldHaveValidDefaultConstructor() {
+ assertThat(DistributionStatusOfServiceInfo.class, hasValidBeanConstructor());
}
@Test
@@ -19,4 +45,14 @@ public class DistributionStatusOfServiceInfoTest {
assertThat(DistributionStatusOfServiceInfo.class, hasValidGettersAndSetters());
}
+ @Test
+ public void shouldTestWhetherTheDefaultConstructorCorrectlySetAllFields() {
+ DistributionStatusOfServiceInfo distributionStatusOfServiceInfo = new DistributionStatusOfServiceInfo(
+ DISTRIBUTION_ID, TIMESTAMP, USER_ID, STATUS);
+ assertThat(distributionStatusOfServiceInfo.getDistributionID(), is(DISTRIBUTION_ID));
+ assertThat(distributionStatusOfServiceInfo.getTimestamp(), is(TIMESTAMP));
+ assertThat(distributionStatusOfServiceInfo.getUserId(), is(USER_ID));
+ assertThat(distributionStatusOfServiceInfo.getDeployementStatus(), is(STATUS));
+ }
+
} \ No newline at end of file