diff options
Diffstat (limited to 'aai-core/src/test/java')
5 files changed, 208 insertions, 208 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java b/aai-core/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java index b4d14d30..198bb064 100644 --- a/aai-core/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java +++ b/aai-core/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java @@ -27,24 +27,24 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class CustomLogPatternLayoutTest { - - /** - * Test null when defaultConverterMap doesn't have corresponding entry. - */ - @Test - public void testNull(){ - String s = CustomLogPatternLayout.defaultConverterMap.get("z"); - assertFalse("Entry not found for key 'z'", CNName.class.getName().equals(s)); - } - - /** - * Test defaultConverterMap when valid entry exists. - */ - @Test - public void testEntryFor_Z(){ - CustomLogPatternLayout layout = new CustomLogPatternLayout(); - String s = CustomLogPatternLayout.defaultConverterMap.get("z"); - assertTrue("Entry not found for key 'z'", CNName.class.getName().equals(s)); - } + + /** + * Test null when defaultConverterMap doesn't have corresponding entry. + */ + @Test + public void testNull(){ + String s = CustomLogPatternLayout.defaultConverterMap.get("z"); + assertFalse("Entry not found for key 'z'", CNName.class.getName().equals(s)); + } + + /** + * Test defaultConverterMap when valid entry exists. + */ + @Test + public void testEntryFor_Z(){ + CustomLogPatternLayout layout = new CustomLogPatternLayout(); + String s = CustomLogPatternLayout.defaultConverterMap.get("z"); + assertTrue("Entry not found for key 'z'", CNName.class.getName().equals(s)); + } } diff --git a/aai-core/src/test/java/org/onap/aai/logging/EcompErrorCategoryTest.java b/aai-core/src/test/java/org/onap/aai/logging/EcompErrorCategoryTest.java index eaa8a536..b29cf51f 100644 --- a/aai-core/src/test/java/org/onap/aai/logging/EcompErrorCategoryTest.java +++ b/aai-core/src/test/java/org/onap/aai/logging/EcompErrorCategoryTest.java @@ -29,7 +29,7 @@ import org.junit.*; public class EcompErrorCategoryTest { - EcompErrorCategory _ecompErrorCategory; + EcompErrorCategory _ecompErrorCategory; ILoggingEvent mockEvent; @Before @@ -41,7 +41,7 @@ public class EcompErrorCategoryTest { } @Test public void warn(){ - String defaultCategory = "WARN"; + String defaultCategory = "WARN"; assertEquals(_ecompErrorCategory.convert(mockEvent), defaultCategory); } diff --git a/aai-core/src/test/java/org/onap/aai/logging/EcompResponseCodeTest.java b/aai-core/src/test/java/org/onap/aai/logging/EcompResponseCodeTest.java index 0bdfc748..10edb456 100644 --- a/aai-core/src/test/java/org/onap/aai/logging/EcompResponseCodeTest.java +++ b/aai-core/src/test/java/org/onap/aai/logging/EcompResponseCodeTest.java @@ -29,7 +29,7 @@ import org.junit.*; public class EcompResponseCodeTest { - EcompResponseCode _ecompResponseCode; + EcompResponseCode _ecompResponseCode; ILoggingEvent mockEvent; @Before diff --git a/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java b/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java index ea361606..8db1ece9 100644 --- a/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java +++ b/aai-core/src/test/java/org/onap/aai/logging/ErrorObjectTest.java @@ -26,136 +26,136 @@ import static org.junit.Assert.*; import org.junit.*; public class ErrorObjectTest { - - ErrorObject newErrorObject = new ErrorObject("disposition","category","severity", 200, "restErrorCode","errorCode","errorText"); - - //Constructor Tests - @Test - public void createObjectTest1(){ - //No HTTP Status argument - ErrorObject errorObject = new ErrorObject("severity","errorcode","errortext","disposition","category"); - assertNotNull(errorObject); - } - @Test - public void createObjectTest2(){ - //HTTP Status code as integer - ErrorObject errorObject = new ErrorObject("severity",200,"errorcode","errortext","disposition","category"); - assertNotNull(errorObject); - } - @Test - public void createObjectTest3(){ - //HTTP Status code as Status - ErrorObject errorObject = new ErrorObject("severity",Status.OK,"errorcode","errortext","disposition","category"); - assertNotNull(errorObject); - } - //Disposition Tests - @Test - public void getDispositionTest() { - assertEquals(newErrorObject.getDisposition(), "disposition"); - } - @Test - public void setDispositionTest() { - newErrorObject.setDisposition("newDisposition"); - assertEquals(newErrorObject.getDisposition(), "newDisposition"); - } - - //Category Tests - @Test - public void getCategoryTest(){ - assertEquals(newErrorObject.getCategory(), "category"); - } - @Test - public void setCategoryTest(){ - newErrorObject.setCategory("newCategory"); - assertEquals(newErrorObject.getCategory(), "newCategory"); - } - - //Severity Tests - @Test - public void getSeverityTest(){ - assertEquals(newErrorObject.getSeverity(), "severity"); - } - @Test - public void setSeverityTest(){ - newErrorObject.setSeverity("newSeverity"); - assertEquals(newErrorObject.getSeverity(), "newSeverity"); - } - - //Error Code Tests - @Test - public void getErrorCodeTest(){ - assertEquals(newErrorObject.getErrorCode(), "errorCode"); - } - @Test - public void SetErrorCodeTest(){ - newErrorObject.setErrorCode("newErrorCode"); - assertEquals(newErrorObject.getErrorCode(), "newErrorCode"); - } - - //HTTP Response Code Tests - @Test - public void getHTTPCodeTest(){ - assertEquals(newErrorObject.getHTTPResponseCode(), Status.OK); - } - @Test - public void setHTTPCodeTest(){ - newErrorObject.setHTTPResponseCode(201); - assertEquals(newErrorObject.getHTTPResponseCode(), Status.CREATED); - } - @Test(expected=IllegalArgumentException.class) - public void invalidHttpCodeTest(){ - newErrorObject.setHTTPResponseCode(6281723); - } - @Test(expected=IllegalArgumentException.class) - public void invalidHttpCodeTest2(){ - newErrorObject.setHTTPResponseCode("82901"); - } - - //Rest Error Code Tests - @Test - public void getRestErrorCodeTest(){ - assertEquals(newErrorObject.getRESTErrorCode(), "restErrorCode"); - } - @Test - public void setRestErrorCodeTest(){ - newErrorObject.setRESTErrorCode("newRestErrorCode"); - assertEquals(newErrorObject.getRESTErrorCode(), "newRestErrorCode"); - } - - //Error Text Tests - @Test - public void getErrorTextTest(){ - assertEquals(newErrorObject.getErrorText(), "errorText"); - } - @Test - public void setErrorTextTest(){ - newErrorObject.setErrorText("newErrorText"); - assertEquals(newErrorObject.getErrorText(), "newErrorText"); - } - @Test - public void getErrorCodeStringTest(){ - assertEquals(newErrorObject.getErrorCodeString(), "disposition.category.errorCode"); - } - @Test - public void getErrorCodeStringDisposition5Test(){ - //get Error Code String while Disposition = 5 - newErrorObject.setDisposition("5"); - assertEquals(newErrorObject.getErrorCodeString(), "ERR.5.category.errorCode"); - } - @Test - public void getSeverityCodeTest(){ - newErrorObject.setSeverity("WARN"); - assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "1"); - - newErrorObject.setSeverity("ERROR"); - assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "2"); - - newErrorObject.setSeverity("FATAL"); - assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "3"); - } - //To String Test - @Test - public void toStringTest(){ - assertEquals(newErrorObject.toString(), "ErrorObject [errorCode=errorCode, errorText=errorText, restErrorCode=restErrorCode, httpResponseCode=OK, severity=severity, disposition=disposition, category=category]"); - } + + ErrorObject newErrorObject = new ErrorObject("disposition","category","severity", 200, "restErrorCode","errorCode","errorText"); + + //Constructor Tests + @Test + public void createObjectTest1(){ + //No HTTP Status argument + ErrorObject errorObject = new ErrorObject("severity","errorcode","errortext","disposition","category"); + assertNotNull(errorObject); + } + @Test + public void createObjectTest2(){ + //HTTP Status code as integer + ErrorObject errorObject = new ErrorObject("severity",200,"errorcode","errortext","disposition","category"); + assertNotNull(errorObject); + } + @Test + public void createObjectTest3(){ + //HTTP Status code as Status + ErrorObject errorObject = new ErrorObject("severity",Status.OK,"errorcode","errortext","disposition","category"); + assertNotNull(errorObject); + } + //Disposition Tests + @Test + public void getDispositionTest() { + assertEquals(newErrorObject.getDisposition(), "disposition"); + } + @Test + public void setDispositionTest() { + newErrorObject.setDisposition("newDisposition"); + assertEquals(newErrorObject.getDisposition(), "newDisposition"); + } + + //Category Tests + @Test + public void getCategoryTest(){ + assertEquals(newErrorObject.getCategory(), "category"); + } + @Test + public void setCategoryTest(){ + newErrorObject.setCategory("newCategory"); + assertEquals(newErrorObject.getCategory(), "newCategory"); + } + + //Severity Tests + @Test + public void getSeverityTest(){ + assertEquals(newErrorObject.getSeverity(), "severity"); + } + @Test + public void setSeverityTest(){ + newErrorObject.setSeverity("newSeverity"); + assertEquals(newErrorObject.getSeverity(), "newSeverity"); + } + + //Error Code Tests + @Test + public void getErrorCodeTest(){ + assertEquals(newErrorObject.getErrorCode(), "errorCode"); + } + @Test + public void SetErrorCodeTest(){ + newErrorObject.setErrorCode("newErrorCode"); + assertEquals(newErrorObject.getErrorCode(), "newErrorCode"); + } + + //HTTP Response Code Tests + @Test + public void getHTTPCodeTest(){ + assertEquals(newErrorObject.getHTTPResponseCode(), Status.OK); + } + @Test + public void setHTTPCodeTest(){ + newErrorObject.setHTTPResponseCode(201); + assertEquals(newErrorObject.getHTTPResponseCode(), Status.CREATED); + } + @Test(expected=IllegalArgumentException.class) + public void invalidHttpCodeTest(){ + newErrorObject.setHTTPResponseCode(6281723); + } + @Test(expected=IllegalArgumentException.class) + public void invalidHttpCodeTest2(){ + newErrorObject.setHTTPResponseCode("82901"); + } + + //Rest Error Code Tests + @Test + public void getRestErrorCodeTest(){ + assertEquals(newErrorObject.getRESTErrorCode(), "restErrorCode"); + } + @Test + public void setRestErrorCodeTest(){ + newErrorObject.setRESTErrorCode("newRestErrorCode"); + assertEquals(newErrorObject.getRESTErrorCode(), "newRestErrorCode"); + } + + //Error Text Tests + @Test + public void getErrorTextTest(){ + assertEquals(newErrorObject.getErrorText(), "errorText"); + } + @Test + public void setErrorTextTest(){ + newErrorObject.setErrorText("newErrorText"); + assertEquals(newErrorObject.getErrorText(), "newErrorText"); + } + @Test + public void getErrorCodeStringTest(){ + assertEquals(newErrorObject.getErrorCodeString(), "disposition.category.errorCode"); + } + @Test + public void getErrorCodeStringDisposition5Test(){ + //get Error Code String while Disposition = 5 + newErrorObject.setDisposition("5"); + assertEquals(newErrorObject.getErrorCodeString(), "ERR.5.category.errorCode"); + } + @Test + public void getSeverityCodeTest(){ + newErrorObject.setSeverity("WARN"); + assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "1"); + + newErrorObject.setSeverity("ERROR"); + assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "2"); + + newErrorObject.setSeverity("FATAL"); + assertEquals(newErrorObject.getSeverityCode(newErrorObject.getSeverity()), "3"); + } + //To String Test + @Test + public void toStringTest(){ + assertEquals(newErrorObject.toString(), "ErrorObject [errorCode=errorCode, errorText=errorText, restErrorCode=restErrorCode, httpResponseCode=OK, severity=severity, disposition=disposition, category=category]"); + } } diff --git a/aai-core/src/test/java/org/onap/aai/logging/LoggingContextTest.java b/aai-core/src/test/java/org/onap/aai/logging/LoggingContextTest.java index 1aafa4a1..0e2a1c3d 100644 --- a/aai-core/src/test/java/org/onap/aai/logging/LoggingContextTest.java +++ b/aai-core/src/test/java/org/onap/aai/logging/LoggingContextTest.java @@ -27,80 +27,80 @@ import static org.junit.Assert.*; public class LoggingContextTest { - private static final int MAX_STORED_CONTEXTS = 100; + private static final int MAX_STORED_CONTEXTS = 100; - @Test - public void testStopWatch() { - try { - LoggingContext.stopWatchStop(); - throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() called without a prior LoggingContext.stopWatchStart()"); - } catch (StopWatchNotStartedException e) { - //Expected - } + @Test + public void testStopWatch() { + try { + LoggingContext.stopWatchStop(); + throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() called without a prior LoggingContext.stopWatchStart()"); + } catch (StopWatchNotStartedException e) { + //Expected + } - LoggingContext.stopWatchStart(); + LoggingContext.stopWatchStart(); - assertTrue(LoggingContext.stopWatchStop() >= 0); + assertTrue(LoggingContext.stopWatchStop() >= 0); - try { - LoggingContext.stopWatchStop(); - throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() twice in succession"); - } catch (StopWatchNotStartedException e) { - //Expected - } - } + try { + LoggingContext.stopWatchStop(); + throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() twice in succession"); + } catch (StopWatchNotStartedException e) { + //Expected + } + } - @Test - public void testRequestId() { //AKA Transaction ID - final String sUuid = "57d51eaa-edc6-4f50-a69d-f2d4d2445120"; + @Test + public void testRequestId() { //AKA Transaction ID + final String sUuid = "57d51eaa-edc6-4f50-a69d-f2d4d2445120"; - LoggingContext.requestId(sUuid); + LoggingContext.requestId(sUuid); - assertEquals(LoggingContext.requestId(), UUID.fromString(sUuid)); + assertEquals(LoggingContext.requestId(), UUID.fromString(sUuid)); - final UUID uuid = UUID.randomUUID(); + final UUID uuid = UUID.randomUUID(); - LoggingContext.requestId(uuid); + LoggingContext.requestId(uuid); - assertEquals(LoggingContext.requestId(), uuid); + assertEquals(LoggingContext.requestId(), uuid); - LoggingContext.requestId("foo"); //Illegal - this will result in a new, randomly - //generated UUID as per the logging spec + LoggingContext.requestId("foo"); //Illegal - this will result in a new, randomly + //generated UUID as per the logging spec - assertNotNull(LoggingContext.requestId()); //Make sure ANY UUID was assigned - assertNotEquals(LoggingContext.requestId(), uuid); //Make sure it actually changed from the last - //known valid UUID - } + assertNotNull(LoggingContext.requestId()); //Make sure ANY UUID was assigned + assertNotEquals(LoggingContext.requestId(), uuid); //Make sure it actually changed from the last + //known valid UUID + } - @Test - public void testClear() { - LoggingContext.init(); - LoggingContext.clear(); + @Test + public void testClear() { + LoggingContext.init(); + LoggingContext.clear(); - assertEquals(Collections.emptyMap(), LoggingContext.getCopy()); - } + assertEquals(Collections.emptyMap(), LoggingContext.getCopy()); + } - @Test - public void testSaveRestore() { + @Test + public void testSaveRestore() { - final Deque<Map<String, String>> contexts = new LinkedList<Map<String, String>> (); + final Deque<Map<String, String>> contexts = new LinkedList<Map<String, String>> (); - LoggingContext.init(); + LoggingContext.init(); - for (int i = 0; i < MAX_STORED_CONTEXTS; i++) { - LoggingContext.customField1(String.valueOf(i)); - - assertEquals(LoggingContext.customField1(), String.valueOf(i)); + for (int i = 0; i < MAX_STORED_CONTEXTS; i++) { + LoggingContext.customField1(String.valueOf(i)); + + assertEquals(LoggingContext.customField1(), String.valueOf(i)); - LoggingContext.save(); + LoggingContext.save(); - contexts.push(LoggingContext.getCopy()); - } + contexts.push(LoggingContext.getCopy()); + } - while (contexts.peek() != null) { - LoggingContext.restore(); + while (contexts.peek() != null) { + LoggingContext.restore(); - assertEquals(LoggingContext.getCopy(), contexts.pop()); - } - } + assertEquals(LoggingContext.getCopy(), contexts.pop()); + } + } } |