Fix test failures 68/138368/2
authorwaynedunican <wayne.dunican@est.tech>
Wed, 3 Jul 2024 08:33:55 +0000 (09:33 +0100)
committerwaynedunican <wayne.dunican@est.tech>
Wed, 3 Jul 2024 09:38:16 +0000 (10:38 +0100)
Fix test failures after removal of ToStringTester in models

Issue-ID: POLICY-5042
Change-Id: I7373cd8f6c2e36685cfdb781734c4b7621174c72
Signed-off-by: waynedunican <wayne.dunican@est.tech>
main/src/test/java/org/onap/policy/pdpx/main/rest/TestStatisticsReport.java

index 550248b..f774e02 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.pdpx.main.rest;
 
-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.test.ToStringTester;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.pdpx.main.rest.model.StatisticsReport;
 
 /**
@@ -37,11 +34,39 @@ import org.onap.policy.pdpx.main.rest.model.StatisticsReport;
  */
 public class TestStatisticsReport {
 
+    static StatisticsReport report;
+
+    @BeforeAll
+    static void setUp() {
+        report = new StatisticsReport();
+    }
+
     @Test
-    public void testStatisticsReport() {
-        final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterMustExistRule())
-                .with(new GetterMustExistRule()).with(new SetterTester()).with(new GetterTester()).build();
-        validator.validate(StatisticsReport.class.getPackage().getName(),
-                new FilterClassName(StatisticsReport.class.getName()));
+    void testStatisticsReportConstructor() {
+        assertNotNull(report);
+    }
+
+    @Test
+    void testGettersAndSetters() {
+        report.setCode(123);
+        report.setApplicationMetrics(null);
+        report.setDenyDecisionsCount(123456);
+        report.setDeployFailureCount(1111);
+        report.setDeploySuccessCount(2222);
+        report.setPermitDecisionsCount(3333);
+        report.setIndeterminantDecisionsCount(4444);
+        report.setNotApplicableDecisionsCount(5555);
+        report.setTotalErrorCount(6666);
+        report.setTotalPoliciesCount(7777);
+        report.setUndeployFailureCount(8888);
+        report.setUndeploySuccessCount(9999);
+        report.setTotalPolicyTypesCount(9898);
+
+        assertThat(report.toString()).contains("code=123", "totalPolicyTypesCount=9898",
+            "totalPoliciesCount=7777", "totalErrorCount=6666", "permitDecisionsCount=3333",
+            "denyDecisionsCount=123456", "deploySuccessCount=2222", "deployFailureCount=1111",
+            "undeploySuccessCount=9999", "undeployFailureCount=8888",
+            "indeterminantDecisionsCount=4444", "notApplicableDecisionsCount=5555",
+            "applicationMetrics=null");
     }
 }