* 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.
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
import java.nio.file.Paths;
import java.util.List;
import java.util.Properties;
/**
* Controller Test Support.
*/
+@Getter
public class ControllerSupport {
protected static final String JUNIT_KMODULE_DRL_PATH = "src/test/resources/lifecycle.drl";
protected static final String SESSION_NAME = "junits";
- @Getter
private final String name;
public ControllerSupport(@NonNull String name) {
ReleaseId coordinates = installArtifact();
+ Properties controllerProps = getControllerProps(coordinates);
+
+ return PolicyControllerConstants.getFactory().build(name, controllerProps);
+ }
+
+ private Properties getControllerProps(ReleaseId coordinates) {
Properties controllerProps = new Properties();
controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, name);
controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_POLICY_TYPES, getPolicyType());
controllerProps.put(DroolsPropertyConstants.RULES_GROUPID, coordinates.getGroupId());
controllerProps.put(DroolsPropertyConstants.RULES_ARTIFACTID, coordinates.getArtifactId());
controllerProps.put(DroolsPropertyConstants.RULES_VERSION, coordinates.getVersion());
-
- return PolicyControllerConstants.getFactory().build(name, controllerProps);
+ return controllerProps;
}
/**
* Install a maven artifact.
*/
public static ReleaseId installArtifact(File kmodule, File pom,
- String drlKjarPath, List<File> drls) throws IOException {
+ String drlKjarPath, List<File> drls) throws IOException {
return KieUtils.installArtifact(kmodule, pom, drlKjarPath, drls);
}
*/
public ReleaseId installArtifact() throws IOException {
return ControllerSupport.installArtifact(Paths.get(JUNIT_KMODULE_PATH).toFile(),
- Paths.get(JUNIT_KMODULE_POM_PATH).toFile(),
- JUNIT_KJAR_DRL_PATH,
- List.of(Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()));
+ Paths.get(JUNIT_KMODULE_POM_PATH).toFile(),
+ JUNIT_KJAR_DRL_PATH,
+ List.of(Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()));
}
/**
* Reassign static field.
*/
public static <T, E> void setStaticField(Class<T> clazz, String fieldName, E newValue)
- throws NoSuchFieldException, IllegalAccessException {
+ throws NoSuchFieldException, IllegalAccessException {
unsetFinalStaticAccess(clazz, fieldName).set(null, newValue);
}
}