From 53b9324d6ec14ef75dc1f943c19b3ea1a46bc8ab Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Fri, 17 Jul 2020 14:08:52 +0100 Subject: Fix assertTrue in apex-pdp/model apex-pdp/plugins, apex-pdp/services and apex-pdp/testsuites Replace assertTrue with assertEquals and assertFalse with assertNotEquals in apex-pdp/model, apex-pdp/plugins, apex-pdp/services and apex-pdp/testsuites Issue-ID: POLICY-2690 Change-Id: If088371cf012d5648e04ade2aa4d49b38945f6d2 Signed-off-by: JvD_Ericsson --- .../plugins/event/carrier/grpc/ApexGrpcConsumerTest.java | 5 ++--- .../apex/plugins/event/protocol/xml/XmlEventHandlerTest.java | 12 +++++++----- .../persistence/jpa/eclipselink/EclipselinkApexDaoTest.java | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'plugins') diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java index 48fce1bee..bd4103f92 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java @@ -23,7 +23,6 @@ package org.onap.policy.apex.plugins.event.carrier.grpc; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import org.assertj.core.api.Assertions; import org.junit.Before; @@ -80,8 +79,8 @@ public class ApexGrpcConsumerTest { grpcConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver); PeeredReference peeredReference = grpcConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR); assertNotNull(peeredReference); - assertTrue(peeredReference.getPeeredConsumer().equals(grpcConsumer)); - assertTrue(peeredReference.getPeeredProducer().equals(grpcProducer)); + assertEquals(grpcConsumer, peeredReference.getPeeredConsumer()); + assertEquals(grpcProducer, peeredReference.getPeeredProducer()); } private EventHandlerParameters populateConsumerParameters(boolean isConsumer, boolean isPeeredMode) { diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java index 28c198cd8..caa3bd06f 100644 --- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java +++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java @@ -21,7 +21,9 @@ package org.onap.policy.apex.plugins.event.protocol.xml; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.util.Date; @@ -62,14 +64,14 @@ public class XmlEventHandlerTest { logger.debug(apexEvent.toString()); assertTrue(apexEvent.getName().equals("Event0000") || apexEvent.getName().equals("Event0100")); - assertTrue(apexEvent.getVersion().equals("0.0.1")); - assertTrue(apexEvent.getNameSpace().equals("org.onap.policy.apex.sample.events")); - assertTrue(apexEvent.getSource().equals("test")); - assertTrue(apexEvent.getTarget().equals("apex")); + assertEquals("0.0.1", apexEvent.getVersion()); + assertEquals("org.onap.policy.apex.sample.events", apexEvent.getNameSpace()); + assertEquals("test", apexEvent.getSource()); + assertEquals("apex", apexEvent.getTarget()); assertTrue(apexEvent.get("TestSlogan").toString().startsWith("Test slogan for External Event")); final Object testMatchCaseSelected = apexEvent.get("TestMatchCaseSelected"); - assertTrue(testMatchCaseSelected == null); + assertNull(testMatchCaseSelected); } } catch (final Exception e) { e.printStackTrace(); diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java index 5098e9301..4f3c68b0f 100644 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java +++ b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 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. @@ -23,7 +24,6 @@ package org.onap.policy.apex.plugins.persistence.jpa.eclipselink; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collections; @@ -85,7 +85,7 @@ public class EclipselinkApexDaoTest { assertNull(eclipselinkApexDao.getArtifact(ReferenceKeyTestEntity.class, nullRefernceKey)); assertNotNull(eclipselinkApexDao.getAll(null)); - assertTrue(eclipselinkApexDao.getAll(null).equals(emptyList)); + assertEquals(emptyList, eclipselinkApexDao.getAll(null)); assertNotNull(eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class)); } @@ -233,7 +233,7 @@ public class EclipselinkApexDaoTest { // test with null class with known key --> return an empty list assertNotNull(eclipselinkApexDao.getAll(null, artiKey1)); - assertTrue(eclipselinkApexDao.getAll(null, artiKey1).equals(Collections.emptyList())); + assertEquals(Collections.emptyList(), eclipselinkApexDao.getAll(null, artiKey1)); // test with (not_null) ArtifactKeyTestEntity class assertEquals(0, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class, artiKey0).size()); -- cgit 1.2.3-korg