diff options
author | Bharat saraswal <bharat.saraswal@huawei.com> | 2017-09-19 21:31:18 +0530 |
---|---|---|
committer | Bharat saraswal <bharat.saraswal@huawei.com> | 2017-09-22 04:14:50 +0000 |
commit | 699852522db59909e8a6cd0fc4f9e592ed800542 (patch) | |
tree | f76d54d5c3d7b3131dc59e66df1fa9875271b08b /dcae-analytics-model/src/test | |
parent | 2c0f2bface56c0cd36bdb1707bc5648792b2e712 (diff) |
Fixing checkstyle and javadoc errors
(followed:onap-java-style) removed redundant code. merged all changes in one commit for one repo.
Issue-Id:DCAEGEN2-92
Change-Id: I072e02dbedd93c01fcf3a297170cb2f7286b3b72
Signed-off-by: Bharat saraswal <bharat.saraswal@huawei.com>
Diffstat (limited to 'dcae-analytics-model/src/test')
7 files changed, 31 insertions, 41 deletions
diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/BaseAnalyticsModelUnitTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/BaseAnalyticsModelUnitTest.java index df69c8c..f0cfd1b 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/BaseAnalyticsModelUnitTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/BaseAnalyticsModelUnitTest.java @@ -43,6 +43,9 @@ public abstract class BaseAnalyticsModelUnitTest extends BaseDCAEAnalyticsUnitTe protected static ObjectMapper objectMapper; + /** + * Before running test cases need to assign object mapper. + */ @BeforeClass public static void beforeClass() { final AnalyticsModelObjectMapperSupplier analyticsModelObjectMapperSupplier = @@ -52,7 +55,7 @@ public abstract class BaseAnalyticsModelUnitTest extends BaseDCAEAnalyticsUnitTe /** - * Deserialize given Json file location to given model class and returns it back without any validation check + * Deserialize given Json file location to given model class and returns it back without any validation check. * * @param jsonFileLocation Classpath location of the json file * @param modelClass Model Class type @@ -81,7 +84,7 @@ public abstract class BaseAnalyticsModelUnitTest extends BaseDCAEAnalyticsUnitTe /** * Deserialize given Json file location to given model class and then validates deserialization by comparing it - * with given expected Object + * with given expected Object. * * @param jsonFileLocation Classpath location of the json file * @param modelClass Model Class type @@ -95,12 +98,18 @@ public abstract class BaseAnalyticsModelUnitTest extends BaseDCAEAnalyticsUnitTe return actualValue; } + /** + * Serialize model to json. + * @param model model + * @return json + * @throws JsonProcessingException when fails to process object + */ public static String serializeModelToJson(Object model) throws JsonProcessingException { return objectMapper.writeValueAsString(model); } /** - * Converts given model to json string and compare it with json present at given file location + * Converts given model to json string and compare it with json present at given file location. * * @param model Model which needs to be compared * @param expectedJsonFileLocation Location of file containing expected json string @@ -114,17 +123,16 @@ public abstract class BaseAnalyticsModelUnitTest extends BaseDCAEAnalyticsUnitTe assertJson(expectedModelString, actualModelString); return model; } catch (IOException | JSONException ex) { - LOG.error("Error while doing assert Json serialization Assertion: model: {}, " + - "expected Json File Location: {}, Exception {}", model, expectedJsonFileLocation, ex); + LOG.error("Error while doing assert Json serialization Assertion: model: {}, " + + "expected Json File Location: {}, Exception {}", model, expectedJsonFileLocation, ex); throw new RuntimeException(ex); } - } /** * Checks both serialization and deserialization. - * + * </p> * First checks deserialization and then serialize the deserialized object back to json * and check if matches the given json file location string * @@ -143,6 +151,4 @@ public abstract class BaseAnalyticsModelUnitTest extends BaseDCAEAnalyticsUnitTe return actualValue; } - - } diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/AAITest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/AAITest.java index d5c5186..3aa6460 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/AAITest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/AAITest.java @@ -33,27 +33,25 @@ import static org.junit.Assert.assertThat; public class AAITest extends BaseAnalyticsModelUnitTest { private AAI aai; + private static final String GENERIC_VNF_ID = "testVNFID"; + private static final String CHANGED_GENERIC_VNF_ID = "changedVNFID"; @Before public void before() { - this.aai = new AAI(); + aai = new AAI(); } @Test public void getGenericVNFId() throws Exception { - final String genericVNFId = "testVNFID"; - aai.setGenericVNFId(genericVNFId); - assertThat("VNFID must be same", aai.getGenericVNFId(), is(genericVNFId)); + aai.setGenericVNFId(GENERIC_VNF_ID); + assertThat("VNFID must be same", aai.getGenericVNFId(), is(GENERIC_VNF_ID)); } @Test public void setGenericVNFId() throws Exception { final String genericVNFId = "testVNFID"; - aai.setGenericVNFId(genericVNFId); - final String changedGenericVNFId = "changedVNFID"; - aai.setGenericVNFId(changedGenericVNFId); - assertThat("VNFID must be same as changed VNFID", aai.getGenericVNFId(), is(changedGenericVNFId)); - + aai.setGenericVNFId(GENERIC_VNF_ID); + aai.setGenericVNFId(CHANGED_GENERIC_VNF_ID); + assertThat("VNFID must be same as changed VNFID", aai.getGenericVNFId(), is(CHANGED_GENERIC_VNF_ID)); } - } diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/TCAVESResponseTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/TCAVESResponseTest.java index 9696823..38dde65 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/TCAVESResponseTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/facade/tca/TCAVESResponseTest.java @@ -31,14 +31,13 @@ import static org.junit.Assert.assertThat; */ public class TCAVESResponseTest extends BaseAnalyticsModelUnitTest { - final String tcaVESCEFResponseJsonFileLocation = "data/json/facade/tca_ves_cef_response.json"; - + private static final String TCA_VES_CEF_RESPONSE_JSON_FILE_LOCATION = "data/json/facade/tca_ves_cef_response.json"; @Test public void testTCAPolicyJsonConversions() throws Exception { final TCAVESResponse vesCEFMessageResponse = - assertJsonConversions(tcaVESCEFResponseJsonFileLocation, TCAVESResponse.class); + assertJsonConversions(TCA_VES_CEF_RESPONSE_JSON_FILE_LOCATION, TCAVESResponse.class); assertThat("VES CEF Message Response AAI generics VNF Id must match", vesCEFMessageResponse.getAai().getGenericVNFId(), is("vpp-test(?)")); @@ -74,5 +73,4 @@ public class TCAVESResponseTest extends BaseAnalyticsModelUnitTest { vesCEFMessageResponse.getClosedLoopEventStatus(), is("ONSET")); } - } diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java index ac8d823..bbfb7f5 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java @@ -54,17 +54,16 @@ public class AnalyticsModelIOUtilsTest extends BaseAnalyticsModelUnitTest { assertEquals("App Description much with json settings file value", "Test App Description", appDescription); } - @Test(expected = RuntimeException.class) + @Test(expected = IOException.class) public void testConvertToJsonObjectWhenFileLocationIsInvValid() throws Exception { AnalyticsModelIOUtils.convertToJsonObject("InvalidFileLocation", ConfigHolder.class); } - @Test(expected = RuntimeException.class) + @Test(expected = IOException.class) public void testConvertToJsonObjectWhenJsonFileHasInvalidJson() throws Exception { AnalyticsModelIOUtils.convertToJsonObject(INVALID_TEST_CONFIG_FILE_LOCATION, ConfigHolder.class); } - @Test public void testValidPropertiesFileLoading() throws Exception { final Properties properties = @@ -82,8 +81,6 @@ public class AnalyticsModelIOUtilsTest extends BaseAnalyticsModelUnitTest { final Properties mockProperties = Mockito.mock(Properties.class); doThrow(new IOException()).when(mockProperties).load(any(InputStream.class)); AnalyticsModelIOUtils.loadPropertiesFile(TEST_PROPERTIES_FILE_LOCATION, mockProperties); - } - } diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/TestAppConfig.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/TestAppConfig.java index 5699192..0bae289 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/TestAppConfig.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/TestAppConfig.java @@ -36,5 +36,3 @@ public class TestAppConfig { return appDescription; } } - - diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/facade/tca/TCAVESResponseMixinTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/facade/tca/TCAVESResponseMixinTest.java index 3285ded..1233d09 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/facade/tca/TCAVESResponseMixinTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/facade/tca/TCAVESResponseMixinTest.java @@ -33,13 +33,13 @@ import static org.junit.Assert.assertThat; */ public class TCAVESResponseMixinTest extends BaseAnalyticsModelUnitTest { - final String tcaVESCEFResponseJsonFileLocation = "data/json/facade/tca_ves_cef_response.json"; + private static final String TCA_VES_CEF_RESPONSE_JSON_FILE_LOCATION = "data/json/facade/tca_ves_cef_response.json"; @Test public void testTCAPolicyJsonConversions() throws Exception { final TCAVESResponse vesCEFMessageResponse = - assertJsonConversions(tcaVESCEFResponseJsonFileLocation, TCAVESResponse.class); + assertJsonConversions(TCA_VES_CEF_RESPONSE_JSON_FILE_LOCATION, TCAVESResponse.class); assertThat("VES CEF Message Response AAI generics VNF Id must match", vesCEFMessageResponse.getAai().getGenericVNFId(), is("vpp-test(?)")); @@ -51,7 +51,5 @@ public class TCAVESResponseMixinTest extends BaseAnalyticsModelUnitTest { vesCEFMessageResponse.getTargetType(), is("VNF")); testSerialization(vesCEFMessageResponse, getClass()); - } - } diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java index a42f816..4084f11 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java @@ -33,12 +33,12 @@ import static org.junit.Assert.assertThat; */ public class TCAPolicyMixinTest extends BaseAnalyticsModelUnitTest { - final String tcaPolicyJsonFileLocation = "data/json/policy/tca_policy.json"; + private static final String TCA_POLICY_JSON_FILE_LOCATION = "data/json/policy/tca_policy.json"; @Test public void testTCAPolicyJsonConversions() throws Exception { - final TCAPolicy tcaPolicy = assertJsonConversions(tcaPolicyJsonFileLocation, TCAPolicy.class); + final TCAPolicy tcaPolicy = assertJsonConversions(TCA_POLICY_JSON_FILE_LOCATION, TCAPolicy.class); assertThat("TCA Policy Metrics Per Event Name must be 2", tcaPolicy.getMetricsPerEventName().size(), is(2)); @@ -47,10 +47,5 @@ public class TCAPolicyMixinTest extends BaseAnalyticsModelUnitTest { tcaPolicy.getMetricsPerEventName().get(0).getThresholds().size(), is(3)); testSerialization(tcaPolicy, getClass()); - } - - - - } |