@Test
public void getRecentSourceEvents() {
- Assert.assertTrue(new NullDroolsController().getRecentSourceEvents().length == 0);
+ Assert.assertEquals(0, new NullDroolsController().getRecentSourceEvents().length);
}
@Test
public void getRecentSinkEvents() {
- Assert.assertTrue(new NullDroolsController().getRecentSinkEvents().length == 0);
+ Assert.assertEquals(0, new NullDroolsController().getRecentSinkEvents().length);
}
@Test
@Test
public void factCount() {
- Assert.assertTrue(new NullDroolsController().factCount(null) == 0);
+ Assert.assertEquals(0, new NullDroolsController().factCount(null));
}
@Test
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
CoderFilters coderFilters = coderToolset.getCoder(Triple.class.getName());
- Assert.assertTrue(coderFilters.getCodedClass() == Triple.class.getName());
- Assert.assertTrue(coderFilters.getFilter() == protocolFilter);
- Assert.assertTrue(coderFilters.getFilter().getRule() != null);
+ Assert.assertSame(coderFilters.getCodedClass(), Triple.class.getName());
+ Assert.assertSame(coderFilters.getFilter(), protocolFilter);
+ Assert.assertNotNull(coderFilters.getFilter().getRule());
coderFilters.getFilter().setRule("[?($.second =~ /^v2$/ && $.third =~ /.*v3.*/)]");
tripleDecoded = (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
- Assert.assertTrue(tripleDecoded.first().equals(triple.first()));
- Assert.assertTrue(tripleDecoded.second().equals(triple.second()));
- Assert.assertTrue(tripleDecoded.third().equals(triple.third()));
+ Assert.assertEquals(triple.first(), tripleDecoded.first());
+ Assert.assertEquals(triple.second(), tripleDecoded.second());
+ Assert.assertEquals(triple.third(), tripleDecoded.third());
coderFilters.getFilter().setRule(null);
Assert.assertEquals("[?($ =~ /.*/)]", coderFilters.getFilter().getRule());
private void addRemoveCoder(ProtocolCoderToolset coderToolset) {
coderToolset.addCoder(this.getClass().getName(),
new JsonProtocolFilter("[?($.second =~ /.*/)]"), 654321);
- Assert.assertTrue(coderToolset.getCoders().size() == 2);
+ Assert.assertEquals(2, coderToolset.getCoders().size());
coderToolset.removeCoders(this.getClass().getName());
- Assert.assertTrue(coderToolset.getCoders().size() == 1);
+ Assert.assertEquals(1, coderToolset.getCoders().size());
}
private void updateCoderFilterRule(ProtocolCoderToolset coderToolset) {
coderToolset.addCoder(Triple.class.getName(), new JsonProtocolFilter("[?($.third =~ /.*/)]"), 654321);
- Assert.assertTrue(coderToolset.getCoders().size() == 1);
+ Assert.assertEquals(1, coderToolset.getCoders().size());
- Assert.assertTrue(coderToolset.getCoder(Triple.class.getName()).getModelClassLoaderHash() == 654321);
+ Assert.assertEquals(654321, coderToolset.getCoder(Triple.class.getName()).getModelClassLoaderHash());
- Assert.assertTrue(
+ Assert.assertNotNull(
coderToolset.getCoder(
- Triple.class.getName()).getFilter().getRule() != null);
+ Triple.class.getName()).getFilter().getRule());
- Assert.assertTrue("[?($.third =~ /.*/)]".equals(coderToolset.getCoder(Triple.class.getName())
- .getFilter().getRule()));
+ Assert.assertEquals("[?($.third =~ /.*/)]", coderToolset.getCoder(Triple.class.getName())
+ .getFilter().getRule());
}
private void validateInitialization(JsonProtocolFilter protocolFilter, ProtocolCoderToolset coderToolset) {
- Assert.assertTrue(CONTROLLER_ID.equals(coderToolset.getControllerId()));
- Assert.assertTrue(releaseId.getGroupId().equals(coderToolset.getGroupId()));
- Assert.assertTrue(releaseId.getArtifactId().equals(coderToolset.getArtifactId()));
+ Assert.assertEquals(CONTROLLER_ID, coderToolset.getControllerId());
+ Assert.assertEquals(releaseId.getGroupId(), coderToolset.getGroupId());
+ Assert.assertEquals(releaseId.getArtifactId(), coderToolset.getArtifactId());
Assert.assertNull(coderToolset.getCustomCoder());
- Assert.assertTrue(coderToolset.getCoders().size() == 1);
+ Assert.assertEquals(1, coderToolset.getCoders().size());
CoderFilters coderFilters = coderToolset.getCoder(CONTROLLER_ID);
- Assert.assertTrue(coderFilters == null);
+ Assert.assertNull(coderFilters);
coderFilters = coderToolset.getCoder(Triple.class.getName());
Assert.assertNotNull(coderFilters);
/*-
* ============LICENSE_START=======================================================
- * Configuration Test
- * ================================================================================
+ * Configuration Test * ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
ControllerConfiguration controllerConfig = new ControllerConfiguration(NAME, OPERATION, DROOLS_CONFIG);
- assertTrue(controllerConfig.equals(controllerConfig));
- assertFalse(controllerConfig.equals(new Object()));
+ assertEquals(controllerConfig, controllerConfig);
+ assertNotEquals(controllerConfig, new Object());
ControllerConfiguration controllerConfig2 = new ControllerConfiguration();
controllerConfig2.setName(NAME2);
additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
final DroolsConfiguration droolsConfig = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
- assertTrue(droolsConfig.equals(droolsConfig));
+ assertEquals(droolsConfig, droolsConfig);
droolsConfig.set(ARTIFACT_ID_STRING, "foobar");
assertEquals("foobar", droolsConfig.get(ARTIFACT_ID_STRING));
package org.onap.policy.drools.protocol.configuration;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotEquals;
import java.io.IOException;
import java.util.ArrayList;
drools.set("version", VERSION);
drools.set(PROPERTY1, VALUE1);
- assertTrue(drools.equals(drools));
- assertFalse(drools.equals(new Object()));
+ assertEquals(drools, drools);
+ assertNotEquals(drools, new Object());
logger.info("Drools HashCode {}", drools.hashCode());
drools2.set(PROPERTY1, drools.get(PROPERTY1));
- assertTrue(drools.equals(drools2));
+ assertEquals(drools, drools2);
//
// with methods
drools2.withArtifactId(ARTIFACT2).withGroupId(GROUPID2).withVersion(VERSION2)
.withAdditionalProperty(PROPERTY2, VALUE2);
- assertFalse(drools.equals(drools2));
+ assertNotEquals(drools, drools2);
//
// Test get additional properties
controller.set("drools", drools);
controller.set(PROPERTY1, VALUE1);
- assertTrue(controller.equals(controller));
- assertFalse(controller.equals(new Object()));
+ assertEquals(controller, controller);
+ assertNotEquals(controller, new Object());
logger.info("Controller HashCode {}", controller.hashCode());
controller2.set(PROPERTY1, controller.get(PROPERTY1));
- assertTrue(controller.equals(controller2));
+ assertEquals(controller, controller2);
//
// test with methods
controller2.withDrools(drools2).withName(NAME2)
.withOperation(OPERATION2).withAdditionalProperty(PROPERTY2, VALUE2);
- assertFalse(controller.equals(controller2));
+ assertNotEquals(controller, controller2);
//
// Test additional properties
config.set("controllers", controllers);
config.set(PROPERTY1, VALUE1);
- assertTrue(config.equals(config));
- assertFalse(config.equals(new Object()));
+ assertEquals(config, config);
+ assertNotEquals(config, new Object());
logger.info("Config HashCode {}", config.hashCode());
config2.set(PROPERTY1, config.get(PROPERTY1));
- assertTrue(config.equals(config2));
+ assertEquals(config, config2);
//
// Test with methods
controllers2.add(controller2);
config2.withRequestId(REQUEST_ID2).withEntity(ENTITY2).withController(controllers2);
- assertFalse(config.equals(config2));
+ assertNotEquals(config, config2);
//
// Test additional properties
verify(prov1).beforeBoot(mgr, args);
verify(prov2).beforeBoot(mgr, args);
- assertTrue(globalInitArgs == args);
+ assertSame(globalInitArgs, args);
verify(prov1).afterBoot(mgr);
verify(prov2).afterBoot(mgr);
(prov, flag) -> when(prov.afterBoot(mgr)).thenReturn(flag),
() -> mgr.boot(args),
prov -> verify(prov).beforeBoot(mgr, args),
- () -> assertTrue(globalInitArgs == args),
+ () -> assertSame(globalInitArgs, args),
prov -> verify(prov).afterBoot(mgr));
}
mgr.setEnvironment(props2);
- assertTrue(mgr.getEnvironment() == env);
+ assertSame(mgr.getEnvironment(), env);
// new env should have a union of the properties
props1.putAll(props2);
package org.onap.policy.drools.system;
import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
controllerProperties.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
PolicyEngineConstants.getManager().createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
- assertTrue(PolicyControllerConstants.getFactory().inventory().size() == 1);
+ assertEquals(1, PolicyControllerConstants.getFactory().inventory().size());
gson.compareGson(PolicyEngineConstants.getManager(),
new File(PolicyEngineTest.class.getSimpleName() + "Add.json"));