summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test/java/org/onap
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-08-28 14:09:39 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-08-28 14:37:20 +0100
commit95751fdf0e69dec1c2850136447679ac344c9230 (patch)
tree7a713c835e8c69ab3b0d625a531c1a5a94f9ccb5 /policy-endpoints/src/test/java/org/onap
parent99b3ae8b86863672ebe410303182d21daeabd0d1 (diff)
Adding usage of openpojo in policy common
* Changing TestHealthCheckReport to use openpojo for testing the HealthCheckReport class. * Adding a custom Tester implementation called ToStringTester as a utility to test toString() method of classes using openpojo. Change-Id: I491a23c471d50454b4d5591c6c09c6758e2c0624 Issue-ID: POLICY-1035 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java38
1 files changed, 14 insertions, 24 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java
index 72bae0cf..fd4cefb0 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java
@@ -20,9 +20,16 @@
package org.onap.policy.common.endpoints.report;
-import static org.junit.Assert.assertEquals;
+import com.openpojo.reflection.filters.FilterClassName;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
import org.junit.Test;
+import org.onap.policy.common.utils.validation.ToStringTester;
/**
* Class to perform unit test of HealthCheckReport.
@@ -32,28 +39,11 @@ import org.junit.Test;
public class TestHealthCheckReport {
@Test
- public void testReport() {
- final String name = "Policy";
- final String url = "self";
- final boolean healthy = true;
- final int code = 200;
- final String message = "alive";
- final HealthCheckReport report = new HealthCheckReport();
- report.setName(name);
- report.setUrl(url);
- report.setHealthy(healthy);
- report.setCode(code);
- report.setMessage(message);
- validateReport(name, url, healthy, code, message, report);
- }
-
- private void validateReport(final String name, final String url, final boolean healthy, final int code,
- final String message, final HealthCheckReport report) {
- assertEquals(name, report.getName());
- assertEquals(url, report.getUrl());
- assertEquals(healthy, report.isHealthy());
- assertEquals(code, report.getCode());
- assertEquals(message, report.getMessage());
- assertEquals("Report [name=Policy, url=self, healthy=true, code=200, message=alive]", report.toString());
+ public void testHealthCheckReport() {
+ final Validator validator =
+ ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule())
+ .with(new GetterTester()).with(new SetterTester()).with(new ToStringTester()).build();
+ validator.validate(HealthCheckReport.class.getPackage().getName(),
+ new FilterClassName(HealthCheckReport.class.getName()));
}
}