From 683a4a788de041d390d57c5a8f71c4d83fff8820 Mon Sep 17 00:00:00 2001 From: rameshiyer27 Date: Wed, 17 Jul 2024 09:12:52 +0100 Subject: Apex pdp code improvements Fix compilation issues in windows Replace Acm policy with kafka coverage improvements Issue-ID: POLICY-5059 Signed-off-by: zrrmmua Change-Id: Idfac722cce2d1a2fa471e8c77286006bd883e9a7 --- .../basicmodel/handling/SupportApexBasicModelTest.java | 12 ++++++++---- .../contextmodel/handling/ApexContextModelTest.java | 12 ++++++++---- .../model/eventmodel/handling/ApexEventModelTest.java | 12 ++++++++---- .../model/policymodel/handling/ApexPolicyModelTest.java | 16 ++++++++++++---- 4 files changed, 36 insertions(+), 16 deletions(-) (limited to 'model') diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java index 8c1f756c1..b5028273c 100644 --- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java +++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java @@ -54,7 +54,7 @@ class SupportApexBasicModelTest { @Test void testModelValid() throws Exception { final AxValidationResult result = testApexModel.testApexModelValid(); - var expectedResult = ResourceUtils.getResourceAsString(VALID_MODEL_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(VALID_MODEL_STRING)); assertEquals(expectedResult, result.toString()); } @@ -67,21 +67,21 @@ class SupportApexBasicModelTest { @Test void testApexModelValidateWarning() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateWarning(); - var expectedResult = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING)); assertEquals(expectedResult, result.toString()); } @Test void testModelValidateInvalidModel() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel(); - var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING)); assertEquals(expectedResult, result.toString()); } @Test void testModelValidateMalstructured() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateMalstructured(); - var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING)); assertEquals(expectedResult, result.toString()); } @@ -89,4 +89,8 @@ class SupportApexBasicModelTest { void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } + + private String normalizeNewlines(String input) { + return input.replace("\r\n", "\n"); + } } diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java index a9cb16914..31083d4c4 100644 --- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java +++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java @@ -68,28 +68,28 @@ class ApexContextModelTest { @Test void testApexModelValidateObservation() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateObservation(); - var expectedResult = ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING)); assertEquals(expectedResult, result.toString()); } @Test void testApexModelValidateWarning() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateWarning(); - var expectedResult = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING)); assertEquals(expectedResult, result.toString()); } @Test void testModelValidateInvalidModel() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel(); - var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING)); assertEquals(expectedResult, result.toString()); } @Test void testModelValidateMalstructured() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateMalstructured(); - var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING); + var expectedResult = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING)); assertEquals(expectedResult, result.toString()); } @@ -97,4 +97,8 @@ class ApexContextModelTest { void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } + + private String normalizeNewlines(String input) { + return input.replace("\r\n", "\n"); + } } diff --git a/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java index df1857c82..bb50fb35e 100644 --- a/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java +++ b/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java @@ -64,28 +64,28 @@ class ApexEventModelTest { @Test void testApexModelValidateObservation() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateObservation(); - String expected = ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING); + var expected = normalizeNewlines(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING)); assertEquals(expected, result.toString()); } @Test void testApexModelValidateWarning() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateWarning(); - String expected = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING); + var expected = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING)); assertEquals(expected, result.toString()); } @Test void testModelValidateInvalidModel() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel(); - String expected = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING); + var expected = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING)); assertEquals(expected, result.toString()); } @Test void testModelValidateMalstructured() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateMalstructured(); - String expected = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING); + var expected = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING)); assertEquals(expected, result.toString()); } @@ -93,4 +93,8 @@ class ApexEventModelTest { void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } + + private String normalizeNewlines(String input) { + return input.replace("\r\n", "\n"); + } } diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java index 01f7062e1..c943befd5 100644 --- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java +++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java @@ -61,29 +61,37 @@ class ApexPolicyModelTest { @Test void testApexModelValidateObservation() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateObservation(); - assertEquals(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING), result.toString()); + var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING)); + assertEquals(expectedOutput, result.toString()); } @Test void testApexModelValidateWarning() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateWarning(); - assertEquals(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING), result.toString()); + var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING)); + assertEquals(expectedOutput, result.toString()); } @Test void testModelValidateInvalidModel() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel(); - assertEquals(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING), result.toString()); + var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING)); + assertEquals(expectedOutput, result.toString()); } @Test void testModelValidateMalstructured() throws Exception { final AxValidationResult result = testApexModel.testApexModelValidateMalstructured(); - assertEquals(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING), result.toString()); + var expectedOutput = normalizeNewlines(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING)); + assertEquals(expectedOutput, result.toString()); } @Test void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } + + private String normalizeNewlines(String input) { + return input.replace("\r\n", "\n"); + } } -- cgit 1.2.3-korg