/*-
* ============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.
package org.onap.policy.apex.model.policymodel.handling;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@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
@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
/*-
* ============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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.policymodel.handling;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
final PolicyAnalyser policyAnalyser = new PolicyAnalyser();
final PolicyAnalysisResult analysisResult = policyAnalyser.analyse(apexModel);
- assertTrue(analysisResult.toString().equals(EXPECTED_ANALYSIS_RESULT));
+ assertEquals(EXPECTED_ANALYSIS_RESULT, analysisResult.toString());
assertNotNull(analysisResult.getUsedContextAlbums());
assertNotNull(analysisResult.getUsedContextSchemas());
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.UUID;
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
final AxKeyInfo leftOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("LeftOnlyKeyInfo", "0.0.1"),
UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f000"), "Left only key info");
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
assertNotNull(policyModelComparer.getContextAlbumComparisonResult());
assertNotNull(policyModelComparer.getContextAlbumKeyDifference());
package org.onap.policy.apex.model.policymodel.handling;
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 java.util.Set;
import java.util.TreeSet;
// not be in the split model
apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
- assertTrue(apexModel.equals(splitApexModel));
+ assertEquals(apexModel, splitApexModel);
final Set<AxArtifactKey> requiredMissingPolicySet = new TreeSet<AxArtifactKey>();
requiredPolicySet.add(new AxArtifactKey("MissingPolicy", "0.0.1"));
// not be in the split model
apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
- assertTrue(apexModel.equals(splitApexModel));
+ assertEquals(apexModel, splitApexModel);
// There's only one policy so a split of this model on that policy should return the same
// model
package org.onap.policy.apex.model.utilities;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.apex.model.utilities.comparison.KeyComparer;
KeyDifference<String> keyDifference = new KeyComparer<String>().compareKeys("Hello", "Goodbye");
assertFalse(keyDifference.isEqual());
- assertTrue("Hello".equals(keyDifference.getLeftKey().toString()));
- assertTrue("Goodbye".equals(keyDifference.getRightKey().toString()));
+ assertEquals("Hello", keyDifference.getLeftKey().toString());
+ assertEquals("Goodbye", keyDifference.getRightKey().toString());
- assertTrue("left key Hello and right key Goodbye differ\n".equals(keyDifference.asString(true)));
- assertTrue("left key Hello and right key Goodbye differ\n".equals(keyDifference.asString(false)));
+ assertEquals("left key Hello and right key Goodbye differ\n", keyDifference.asString(true));
+ assertEquals("left key Hello and right key Goodbye differ\n", keyDifference.asString(false));
KeyDifference<String> keyDifference2 = new KeyComparer<String>().compareKeys("Here", "Here");
- assertTrue("".equals(keyDifference2.asString(true)));
- assertTrue("left key Here equals right key Here\n".equals(keyDifference2.asString(false)));
+ assertEquals("", keyDifference2.asString(true));
+ assertEquals("left key Here equals right key Here\n", keyDifference2.asString(false));
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.TreeMap;
import org.junit.Test;
KeyedMapDifference<String, String> kmComparedDiff =
new KeyedMapComparer<String, String>().compareMaps(leftMap, rightMap);
- assertTrue(kmComparedSame.getIdenticalValues().equals(leftMap));
+ assertEquals(leftMap, kmComparedSame.getIdenticalValues());
assertEquals(1, kmComparedDiff.getLeftOnly().size());
assertEquals(3, kmComparedDiff.getRightOnly().size());
assertEquals(2, kmComparedDiff.getDifferentValues().size());
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;
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) {
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;
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();
/*-
* ============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.
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;
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));
}
// 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());
apexMain.shutdown();
final String outString = outContent.toString();
assertTrue(outString.contains("I/O Parameters for id2:v2 has duplicates. So this policy is not executed"));
- assertTrue(apexMain.getApexParametersMap().size() == 1); // only id1:v1 is kept in the map, id2:v2 failed
+ assertEquals(1, apexMain.getApexParametersMap().size()); // only id1:v1 is kept in the map, id2:v2 failed
}
@Test
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 org.junit.After;
public void testApexStarter_NoArguments() {
final String[] apexStarterConfigParameters = {};
apexStarter = new ApexStarterMain(apexStarterConfigParameters);
- assertTrue(apexStarter.getParameters() == null);
+ assertNull(apexStarter.getParameters());
}
@Test
public void testApexStarter_InvalidArguments() {
final String[] apexStarterConfigParameters = { "src/test/resources/ApexStarterConfigParameters.json" };
apexStarter = new ApexStarterMain(apexStarterConfigParameters);
- assertTrue(apexStarter.getParameters() == null);
+ assertNull(apexStarter.getParameters());
}
@Test
final String[] apexStarterConfigParameters =
{ "-c", "src/test/resources/ApexStarterConfigParameters_InvalidName.json" };
apexStarter = new ApexStarterMain(apexStarterConfigParameters);
- assertTrue(apexStarter.getParameters() == null);
+ assertNull(apexStarter.getParameters());
}
}
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.io.IOException;
import java.util.Date;
final double temp2 = (double) event.get("TestTemperature");
assertNotNull(temp2);
- assertTrue(temp2 == 123.456789);
+ assertEquals(123.456789, temp2, 0);
final Double temp3 = (Double) event.get("TestTemperature");
assertNotNull(temp3);
- assertTrue(temp3 == 123.456789);
+ assertEquals(123.456789, temp3, 0);
final Date aDate = new Date(1433453067123L);
final Map<String, Object> eventDataList = new HashMap<String, Object>();
final double temp4 = (double) event.get("TestTemperature");
assertNotNull(temp4);
- assertTrue(temp4 == 34.5445667);
+ assertEquals(34.5445667, temp4, 0);
logger.debug(event.toString());
}
package org.onap.policy.apex.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem00B", "0.0.1"));
model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem00C", "0.0.1"));
- assertTrue(model.equals(exportedModel0));
+ assertEquals(model, exportedModel0);
exportPolicyList.remove(0);
final AxPolicyModel exportedModel1 = PolicyModelSplitter.getSubPolicyModel(model, exportPolicyList);
- assertFalse(model.equals(exportedModel1));
- assertTrue(model.getPolicies().get("Policy1").equals(exportedModel1.getPolicies().get("Policy1")));
+ assertNotEquals(model, exportedModel1);
+ assertEquals(model.getPolicies().get("Policy1"), exportedModel1.getPolicies().get("Policy1"));
exportPolicyList.clear();
exportPolicyList.add(new AxArtifactKey("NonExistentPolicy", "0.0.1"));
/*-
* ============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.
package org.onap.policy.apex.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import java.sql.Connection;
import java.sql.DriverManager;
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ assertEquals(VALID_MODEL_STRING, result.toString());
}
/**
/*-
* ============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.
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 java.io.IOException;
import org.junit.After;
@Before
public void beforeTest() {
schemaParameters = new SchemaParameters();
-
+
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
ParameterService.register(schemaParameters);
-
+
contextParameters = new ContextParameters();
contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
ParameterService.register(contextParameters.getDistributorParameters());
ParameterService.register(contextParameters.getLockManagerParameters());
ParameterService.register(contextParameters.getPersistorParameters());
-
+
engineParameters = new EngineParameters();
engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters());
ParameterService.register(engineParameters);
@After
public void afterTest() {
ParameterService.deregister(engineParameters);
-
+
ParameterService.deregister(contextParameters.getDistributorParameters());
ParameterService.deregister(contextParameters.getLockManagerParameters());
ParameterService.deregister(contextParameters.getPersistorParameters());
assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
apexModelSample.getAlbums().getAlbumsMap().size());
for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
- assertTrue(
- contextAlbum.getAlbumDefinition().equals(apexModelSample.getAlbums().get(contextAlbum.getKey())));
+ assertEquals(
+ contextAlbum.getAlbumDefinition(), apexModelSample.getAlbums().get(contextAlbum.getKey()));
}
apexEngine.updateModel(someSpuriousModel, false);
assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
someSpuriousModel.getAlbums().getAlbumsMap().size());
for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
- assertTrue(
- contextAlbum.getAlbumDefinition().equals(someSpuriousModel.getAlbums().get(contextAlbum.getKey())));
+ assertEquals(
+ contextAlbum.getAlbumDefinition(), someSpuriousModel.getAlbums().get(contextAlbum.getKey()));
}
apexEngine.clear();
private void checkResult(final ApexEvent result) {
assertTrue(result.getName().startsWith("Event0004") || result.getName().startsWith("Event0104"));
- assertTrue(result.get("TestSlogan").equals("This is a test slogan"));
- assertTrue(result.get("TestMatchCase").equals((byte) 123));
- assertTrue(result.get("TestTemperature").equals(34.5445667));
+ assertEquals("This is a test slogan", result.get("TestSlogan"));
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
assertTrue(((byte) result.get("TestMatchCaseSelected")) >= 0
&& ((byte) result.get("TestMatchCaseSelected") <= 3));
assertTrue(((byte) result.get("TestEstablishCaseSelected")) >= 0
private void checkResult(final ApexEvent result) {
assertTrue(result.getName().startsWith("Event0004") || result.getName().startsWith("Event0104"));
- assertTrue(result.get("TestSlogan").equals("This is a test slogan"));
- assertTrue(result.get("TestMatchCase").equals((byte) 123));
- assertTrue(result.get("TestTemperature").equals(34.5445667));
+ assertEquals("This is a test slogan", result.get("TestSlogan"));
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
assertTrue(((byte) result.get("TestMatchCaseSelected")) >= 0
&& ((byte) result.get("TestMatchCaseSelected") <= 3));
assertTrue(((byte) result.get("TestEstablishCaseSelected")) >= 0