diff options
author | JvD_Ericsson <jeff.van.dam@est.tech> | 2020-07-17 13:18:37 +0100 |
---|---|---|
committer | JvD_Ericsson <jeff.van.dam@est.tech> | 2020-07-17 16:19:28 +0100 |
commit | 025d5085d56bd1afc60ea8ad0c339655ca373f28 (patch) | |
tree | c36896502a7e0e9d182770a0d94afc8e216a0f17 /model/event-model/src/test | |
parent | 28eced32d2acdf731f7782e14f37bf2ea8c98019 (diff) |
Fix assertTrue SONAR issues in apex-pdp/model
Replace assertTrue with assertEquals and assertFalse with
assertNotEquals in apex-pdp/model
Issue-ID: POLICY-2690
Change-Id: Id37989ea8a6ad7b3156e13851cc072ce6c53c03e
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'model/event-model/src/test')
4 files changed, 51 insertions, 55 deletions
diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java index 3ae5ac267..c86ba12e7 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,8 @@ package org.onap.policy.apex.model.eventmodel.concepts; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import org.junit.Test; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -59,20 +57,20 @@ public class EventModelTest { final AxEventModel clonedModel = new AxEventModel(model); - assertFalse(model.hashCode() == 0); + assertNotEquals(0, model.hashCode()); - assertTrue(model.equals(model)); - assertTrue(model.equals(clonedModel)); - assertFalse(model.equals((Object) "Hello")); - assertFalse(model.equals(new AxEventModel(new AxArtifactKey()))); - assertFalse(model.equals(new AxEventModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey), - new AxEvents(eventsKey)))); - assertFalse(model.equals(new AxEventModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(), - new AxEvents(eventsKey)))); - assertFalse(model.equals(new AxEventModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents()))); - assertTrue(model.equals(new AxEventModel(modelKey, new AxContextSchemas(schemasKey), - new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey)))); + assertEquals(model, model); + assertEquals(model, clonedModel); + assertNotEquals(model, (Object) "Hello"); + assertNotEquals(model, new AxEventModel(new AxArtifactKey())); + assertNotEquals(model, new AxEventModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey), + new AxEvents(eventsKey))); + assertNotEquals(model, new AxEventModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(), + new AxEvents(eventsKey))); + assertNotEquals(model, new AxEventModel(modelKey, new AxContextSchemas(schemasKey), + new AxKeyInformation(keyInfoKey), new AxEvents())); + assertEquals(model, new AxEventModel(modelKey, new AxContextSchemas(schemasKey), + new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))); assertEquals(0, model.compareTo(model)); assertEquals(0, model.compareTo(clonedModel)); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java index a82be12be..629df1a5f 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ package org.onap.policy.apex.model.eventmodel.concepts; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -186,19 +185,19 @@ public class EventsTest { assertEquals("AxEvent:(key=AxArtifactKey:(name=EventName,version=0.0.1),nameSpace=namespace", clonedEvent.toString().substring(0, 77)); - assertFalse(event.hashCode() == 0); + assertNotEquals(0, event.hashCode()); - assertTrue(event.equals(event)); - assertTrue(event.equals(clonedEvent)); - assertFalse(event.equals(null)); - assertFalse(event.equals((Object) "Hello")); - assertFalse( - event.equals(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap))); - assertFalse(event.equals(new AxEvent(eventKey, "namespace1", "source", "target", parameterMap))); - assertFalse(event.equals(new AxEvent(eventKey, "namespace", "source2", "target", parameterMap))); - assertFalse(event.equals(new AxEvent(eventKey, "namespace", "source", "target3", parameterMap))); - assertFalse(event.equals(new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty))); - assertTrue(event.equals(new AxEvent(eventKey, "namespace", "source", "target", parameterMap))); + assertEquals(event, event); + assertEquals(event, clonedEvent); + assertNotNull(event); + assertNotEquals(event, (Object) "Hello"); + assertNotEquals( + event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap)); + assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap)); + assertNotEquals(event, new AxEvent(eventKey, "namespace", "source2", "target", parameterMap)); + assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target3", parameterMap)); + assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty)); + assertEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMap)); assertEquals(0, event.compareTo(event)); assertEquals(0, event.compareTo(clonedEvent)); @@ -269,13 +268,13 @@ public class EventsTest { assertEquals("AxEvents:(key=AxArtifactKey:(name=EventsKey,version=0.0.1),e", clonedEvents.toString().substring(0, 60)); - assertFalse(events.hashCode() == 0); + assertNotEquals(0, events.hashCode()); - assertTrue(events.equals(events)); - assertTrue(events.equals(clonedEvents)); - assertFalse(events.equals(null)); - assertFalse(events.equals((Object) "Hello")); - assertFalse(events.equals(new AxEvents(new AxArtifactKey()))); + assertEquals(events, events); + assertEquals(events, clonedEvents); + assertNotNull(events); + assertNotEquals(events, (Object) "Hello"); + assertNotEquals(events, new AxEvents(new AxArtifactKey())); assertEquals(0, events.compareTo(events)); assertEquals(0, events.compareTo(clonedEvents)); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java index a2587b503..e5a01ed6f 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,8 @@ package org.onap.policy.apex.model.eventmodel.concepts; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import org.junit.Test; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -35,7 +33,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat /** * Test fields. - * + * * @author Liam Fallon (liam.fallon@ericsson.com) */ public class FieldTest { @@ -110,16 +108,16 @@ public class FieldTest { + "parentLocalName=PLN,localName=LN),fieldSchemaKey=" + "AxArtifactKey:(name=SchemaName,version=0.0.1),optional=true)", clonedField.toString()); - assertFalse(field.hashCode() == 0); + assertNotEquals(0, field.hashCode()); - assertTrue(field.equals(field)); - assertTrue(field.equals(clonedField)); - assertFalse(field.equals(null)); - assertFalse(field.equals((Object) "Hello")); - assertFalse(field.equals(new AxField(AxReferenceKey.getNullKey(), AxArtifactKey.getNullKey(), false))); - assertFalse(field.equals(new AxField(fieldKey, AxArtifactKey.getNullKey(), false))); - assertFalse(field.equals(new AxField(fieldKey, schemaKey, false))); - assertTrue(field.equals(new AxField(fieldKey, schemaKey, true))); + assertEquals(field, field); + assertEquals(field, clonedField); + assertNotNull(field); + assertNotEquals(field, (Object) "Hello"); + assertNotEquals(field, new AxField(AxReferenceKey.getNullKey(), AxArtifactKey.getNullKey(), false)); + assertNotEquals(field, new AxField(fieldKey, AxArtifactKey.getNullKey(), false)); + assertNotEquals(field, new AxField(fieldKey, schemaKey, false)); + assertEquals(field, new AxField(fieldKey, schemaKey, true)); assertEquals(0, field.compareTo(field)); assertEquals(0, field.compareTo(clonedField)); diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java index db752a61b..c31597413 100644 --- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java +++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.apex.model.eventmodel.handling; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; @@ -45,31 +46,31 @@ public class ApexEventModelTest { @Test public void testModelValid() throws Exception { final AxValidationResult result = testApexModel.testApexModelValid(); - assertTrue(result.toString().equals(VALID_MODEL_STRING)); + assertEquals(VALID_MODEL_STRING, result.toString()); } @Test public void testApexModelVaidateObservation() throws Exception { final AxValidationResult result = testApexModel.testApexModelVaidateObservation(); - assertTrue(result.toString().equals(OBSERVATION_MODEL_STRING)); + assertEquals(OBSERVATION_MODEL_STRING, result.toString()); } @Test public void testApexModelVaidateWarning() throws Exception { final AxValidationResult result = testApexModel.testApexModelVaidateWarning(); - assertTrue(result.toString().equals(WARNING_MODEL_STRING)); + assertEquals(WARNING_MODEL_STRING, result.toString()); } @Test public void testModelVaidateInvalidModel() throws Exception { final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel(); - assertTrue(result.toString().equals(INVALID_MODEL_STRING)); + assertEquals(INVALID_MODEL_STRING, result.toString()); } @Test public void testModelVaidateMalstructured() throws Exception { final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured(); - assertTrue(result.toString().equals(INVALID_MODEL_MALSTRUCTURED_STRING)); + assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString()); } @Test |