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>
* 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;
private ComponentInstance node;
private RequirementCapabilityRelDef associate;
+ CreateAndAssotiateInfo() {}
+
public CreateAndAssotiateInfo(ComponentInstance node, RequirementCapabilityRelDef associate) {
- super();
this.node = node;
this.associate = associate;
}
* 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.openecomp.sdc.common.datastructure.ESTimeBasedEvent;
public class DistributionStatusInfo {
- String omfComponentID;
- String timestamp;
- String url;
- String status;
- String errorReason;
+
+ private String omfComponentID;
+ private String timestamp;
+ private String url;
+ private String status;
+ private String errorReason;
+
+ DistributionStatusInfo() {
+ }
public DistributionStatusInfo(ESTimeBasedEvent distributionStatusEvent) {
- super();
- omfComponentID = (String) distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName());
- timestamp = (String) distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TIME.getDisplayName());
- url = (String) distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName());
- status = (String) distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_STATUS.getDisplayName());
- errorReason = (String) distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DESC.getDisplayName());
+ omfComponentID = String.valueOf(distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName()));
+ timestamp = String.valueOf(distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TIME.getDisplayName()));
+ url = String.valueOf(distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName()));
+ status = String.valueOf(distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_STATUS.getDisplayName()));
+ errorReason = String.valueOf(distributionStatusEvent.getFields().get(AuditingFieldsKey.AUDIT_DESC.getDisplayName()));
}
public DistributionStatusInfo(String omfComponentID, String timestamp, String url, String status) {
- super();
this.omfComponentID = omfComponentID;
this.timestamp = timestamp;
this.url = url;
* 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;
public class DistributionStatusOfServiceInfo {
- String distributionID;
- String timestamp;
- String userId;
- String deployementStatus;
+ private String distributionID;
+ private String timestamp;
+ private String userId;
+ private String deployementStatus;
- public DistributionStatusOfServiceInfo() {
- super();
+ public DistributionStatusOfServiceInfo() {}
- }
-
- public DistributionStatusOfServiceInfo(String distributionID, String timestamp, String userId, String deployementStatus) {
+ public DistributionStatusOfServiceInfo(String distributionID, String timestamp, String userId, String deploymentStatus) {
super();
this.distributionID = distributionID;
this.timestamp = timestamp;
this.userId = userId;
- this.deployementStatus = deployementStatus;
+ this.deployementStatus = deploymentStatus;
}
public String getDistributionID() {
+/*-
+ * ============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
+/*-
+ * ============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
+/*-
+ * ============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;
public void shouldHaveValidGettersAndSetters() {
assertThat(DistributionStatusListResponse.class, hasValidGettersAndSetters());
}
+
+ @Test
+ public void shouldHaveValidDefaultConstructor() {
+ assertThat(DistributionStatusListResponse.class, hasValidBeanConstructor());
+ }
}
\ No newline at end of file
+/*-
+ * ============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
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