* ONAP
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 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.drools.controller.internal;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.kie.api.builder.ReleaseId;
import org.kie.api.event.rule.AfterMatchFiredEvent;
import org.kie.api.event.rule.AgendaEventListener;
/**
* Test Class Initialization.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws IOException {
+ Path path = Paths.get(DROOLS_RESOURCES_DIR + "rules1" + DRL_EXT);
rulesDescriptor1 =
install("rules1",
- Stream.of(Paths.get(DROOLS_RESOURCES_DIR + "rules1" + DRL_EXT).toFile()).collect(Collectors.toList()));
+ Stream.of(path.toFile()).collect(Collectors.toList()));
rulesDescriptor2 =
install("rules2",
- Stream.of(Paths.get(DROOLS_RESOURCES_DIR + "rules1" + DRL_EXT).toFile(),
+ Stream.of(path.toFile(),
Paths.get(DROOLS_RESOURCES_DIR + "rules2" + DRL_EXT).toFile())
.collect(Collectors.toList()));
/**
* Creates a controller before each test.
*/
- @Before
+ @BeforeEach
public void beforeTest() {
controller =
new MavenDroolsController(
/**
* Shuts down the controller after each test.
*/
- @After
+ @AfterEach
public void afterTest() {
if (controller != null) {
controller.halt();
* Upgrades test.
*/
@Test
- public void upgrades() throws InterruptedException {
+ void upgrades() throws InterruptedException {
assertTrue(controller.start());
logKieEvents();
assertTrue(running1a.await(30, TimeUnit.SECONDS));
summary();
- assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"), 1);
+ assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"));
controller.updateToVersion(
rulesDescriptor2.getGroupId(),
assertTrue(running2b.await(30, TimeUnit.SECONDS));
assertTrue(running1b.await(30, TimeUnit.SECONDS));
summary();
- assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12", "SETUP.2", "VERSION.2"), 1);
+ assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12", "SETUP.2", "VERSION.2"));
controller.updateToVersion(
rulesDescriptor1.getGroupId(),
null, null);
summary();
- assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"), 1);
+ assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"));
}
private void summary() {
logger.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
- private void assertKie(List<String> expectedRuleNames, long expectedFactCount) {
+ private void assertKie(List<String> expectedRuleNames) {
assertEquals(Collections.singletonList("kbRules"),
KieUtils.getBases(controller.getContainer().getKieContainer()));
assertEquals(expectedRuleNames, KieUtils.getRuleNames(controller.getContainer().getKieContainer()));
- assertEquals(expectedFactCount, controller.factCount(controller.getSessionNames().get(0)));
+ assertEquals(1, controller.factCount(controller.getSessionNames().get(0)));
}
private void logKieEvents() {