/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static final String EXAMPLE_NATIVE_CONTROLLER_POLICY_NAME = "example.controller";
private static final String EXAMPLE_NATIVE_CONTROLLER_POLICY_JSON =
- "src/test/resources/tosca-policy-native-controller-example.json";
+ "src/test/resources/tosca-policy-native-controller-example.json";
private static final String EXAMPLE_NATIVE_ARTIFACT_POLICY_NAME = "example.artifact";
private static final String EXAMPLE_NATIVE_ARTIFACT_POLICY_JSON =
- "src/test/resources/tosca-policy-native-artifact-example.json";
+ "src/test/resources/tosca-policy-native-artifact-example.json";
private static final String EXAMPLE_OTHER_UNVAL_POLICY_NAME = "other-unvalidated";
private static final String EXAMPLE_OTHER_UNVAL_POLICY_JSON =
- "src/test/resources/tosca-policy-other-unvalidated.json";
+ "src/test/resources/tosca-policy-other-unvalidated.json";
private static final String EXAMPLE_OTHER_VAL_POLICY_NAME = "other-validated";
private static final String EXAMPLE_OTHER_VAL_POLICY_JSON = "src/test/resources/tosca-policy-other-validated.json";
private static final String FOO_NATIVE_CONTROLLER_POLICY_NAME = "foo.controller";
private static final String FOO_NATIVE_CONTROLLER_POLICY_JSON =
- "src/test/resources/tosca-policy-native-controller-foo.json";
+ "src/test/resources/tosca-policy-native-controller-foo.json";
private static final String FOO_NATIVE_ARTIFACT_POLICY_NAME = "foo.artifact";
private static final String FOO_NATIVE_ARTIFACT_POLICY_JSON =
- "src/test/resources/tosca-policy-native-artifact-foo.json";
+ "src/test/resources/tosca-policy-native-artifact-foo.json";
private static final String VCPE_OP_POLICY_NAME = "operational.restart";
private static final String VCPE_OPERATIONAL_DROOLS_POLICY_JSON =
- "policies/vCPE.policy.operational.input.tosca.json";
+ "policies/vCPE.policy.operational.input.tosca.json";
private static final String VFW_OP_POLICY_NAME = "operational.modifyconfig";
private static final String VFW_OPERATIONAL_DROOLS_POLICY_JSON =
- "policies/vFirewall.policy.operational.input.tosca.json";
+ "policies/vFirewall.policy.operational.input.tosca.json";
private static final StandardCoder coder = new StandardCoder();
NoopTopicFactories.getSinkFactory().destroy();
try {
Files.deleteIfExists(Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
- "lifecycle-controller.properties.bak"));
+ "lifecycle-controller.properties.bak"));
Files.deleteIfExists(Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
- "foo-controller.properties.bak"));
+ "foo-controller.properties.bak"));
} catch (IOException ignored) { // NOSONAR
// checkstyle
}
opPolicy = getExamplesPolicy(VFW_OPERATIONAL_DROOLS_POLICY_JSON, VFW_OP_POLICY_NAME);
op2Policy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, VCPE_OP_POLICY_NAME);
controllerPolicy =
- getPolicyFromFile(EXAMPLE_NATIVE_CONTROLLER_POLICY_JSON, EXAMPLE_NATIVE_CONTROLLER_POLICY_NAME);
+ getPolicyFromFile(EXAMPLE_NATIVE_CONTROLLER_POLICY_JSON, EXAMPLE_NATIVE_CONTROLLER_POLICY_NAME);
controller2Policy = getPolicyFromFile(FOO_NATIVE_CONTROLLER_POLICY_JSON, FOO_NATIVE_CONTROLLER_POLICY_NAME);
artifactPolicy = getPolicyFromFile(EXAMPLE_NATIVE_ARTIFACT_POLICY_JSON, EXAMPLE_NATIVE_ARTIFACT_POLICY_NAME);
artifact2Policy = getExamplesPolicy(FOO_NATIVE_ARTIFACT_POLICY_JSON, FOO_NATIVE_ARTIFACT_POLICY_NAME);
// native controller policy - deploy
// Delta: +controllerPolicy
- deltaUpdate(List.of(controllerPolicy), List.of(), List.of(controllerPolicy), 1, 1, 0, 0, 0, 0);
+ deltaUpdate(List.of(controllerPolicy), List.of(), List.of(controllerPolicy));
// no policies - undeploy
// Delta: -controllerPolicy
- deltaUpdate(List.of(), List.of(controllerPolicy), List.of(), 1, 1, 0, 1, 1, 0);
+ deltaUpdate(List.of(), List.of(controllerPolicy), List.of());
// native controller + artifact policy (out of order) - deploy
// Delta: +artifactPolicy, +controllerPolicy
- deltaUpdate(List.of(artifactPolicy, controllerPolicy), List.of(), List.of(artifactPolicy, controllerPolicy), 3,
- 3, 0, 1, 1, 0);
+ deltaUpdate(List.of(artifactPolicy, controllerPolicy), List.of(),
+ List.of(artifactPolicy, controllerPolicy));
// attempt to deploy opPolicy but invalid controller
// Delta: +opPolicy
assertEquals(1, PolicyControllerConstants.getFactory().inventory().size());
assertFalse(fsm.getActivePolicies().contains(opPolicy));
verifyExists(false, "lifecycle", List.of(opPolicy));
- verifyDeploy(List.of(artifactPolicy, controllerPolicy), 4, 3, 1, 1, 1, 0);
+ verifyDeploy(List.of(artifactPolicy, controllerPolicy));
// Delta: +opPolicy
opPolicy.getProperties().remove("controllerName");
- deltaUpdate(List.of(opPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy), 5, 4, 1, 1, 1,
- 0);
+ deltaUpdate(List.of(opPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: -opPolicy
- deltaUpdate(List.of(), List.of(opPolicy), List.of(controllerPolicy, artifactPolicy), 5, 4, 1, 2, 2, 0);
+ deltaUpdate(List.of(), List.of(opPolicy), List.of(controllerPolicy, artifactPolicy));
assertFalse(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().exists(opPolicy));
// Delta: -artifactPolicy
- deltaUpdate(List.of(), List.of(artifactPolicy), List.of(controllerPolicy), 5, 4, 1, 3, 3, 0);
+ deltaUpdate(List.of(), List.of(artifactPolicy), List.of(controllerPolicy));
assertFalse(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().isBrained());
// Delta: -controllerPolicy
- deltaUpdate(List.of(), List.of(controllerPolicy), List.of(), 5, 4, 1, 4, 4, 0);
+ deltaUpdate(List.of(), List.of(controllerPolicy), List.of());
assertThatIllegalArgumentException().isThrownBy(() -> PolicyControllerConstants.getFactory().get("lifecycle"));
// Delta: +controllerPolicy, +artifactPolicy, and +opPolicy
deltaUpdate(List.of(opPolicy, artifactPolicy, controllerPolicy), List.of(),
- List.of(opPolicy, artifactPolicy, controllerPolicy), 8, 7, 1, 4, 4, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: -artifactPolicy
// Delta: +artifactPolicy
// from deltas, all delta updates should be successfully applied
- deltaUpdate(List.of(artifactPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy), 9, 8, 1, 5,
- 5, 0);
+ deltaUpdate(List.of(artifactPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: -controllerPolicy
// Delta: +controllerPolicy
// from deltas, all delta updates should be successfully applied
- deltaUpdate(List.of(controllerPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy), 10, 9, 1,
- 6, 6, 0);
+ deltaUpdate(List.of(controllerPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: +op2Policy, +controller2Policy
// from deltas, all delta updates should be successfully applied
op2Policy.getProperties().put("controllerName", "lifecycle");
deltaUpdate(List.of(op2Policy, controller2Policy), List.of(),
- List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy), 12, 11, 1, 6, 6, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy));
assertFalse(PolicyControllerConstants.getFactory().get("foo").getDrools().isBrained());
// same operation with duplicates - idempotent operation
deltaUpdate(List.of(op2Policy, controller2Policy, opPolicy), List.of(valPolicy, unvalPolicy),
- List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy), 12, 11, 1, 6, 6, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy));
assertFalse(PolicyControllerConstants.getFactory().get("foo").getDrools().isBrained());
// Delta: +artifact2policy, +valPolicy, +unvalPolicy
// from deltas, all delta updates should be successfully applied
- deltaUpdate(
- List.of(valPolicy, unvalPolicy, artifact2Policy), List.of(), List.of(opPolicy, artifactPolicy,
- controllerPolicy, op2Policy, controller2Policy, valPolicy, unvalPolicy, artifact2Policy),
- 15, 14, 1, 6, 6, 0);
+ deltaUpdate(List.of(valPolicy, unvalPolicy, artifact2Policy), List.of(), List.of(opPolicy, artifactPolicy,
+ controllerPolicy, op2Policy, controller2Policy, valPolicy, unvalPolicy, artifact2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy, valPolicy, unvalPolicy));
verifyExists(true, "foo", List.of(valPolicy, unvalPolicy));
verifyExists(false, "foo", List.of(opPolicy, op2Policy));
// Delta: -artifact2Policy, -unvalPolicy
// from deltas, all delta updates should be successfully applied, and unvalPolicy disabled
deltaUpdate(List.of(), List.of(artifact2Policy, unvalPolicy),
- List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy, valPolicy), 15, 14, 1,
- 8, 8, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy, valPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy, valPolicy));
verifyExists(false, "lifecycle", List.of(unvalPolicy));
assertFalse(PolicyControllerConstants.getFactory().get("foo").getDrools().isBrained());
// should be re-applied.
assertTrue(fsm.update(getPdpUpdate(List.of(artifact2Policy), List.of())));
deltaUpdate(List.of(artifact2Policy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy,
- controller2Policy, valPolicy, artifact2Policy), 16, 15, 1, 8, 8, 0);
+ controller2Policy, valPolicy, artifact2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy, valPolicy));
verifyExists(false, "lifecycle", List.of(unvalPolicy));
verifyExists(true, "foo", List.of(valPolicy));
// since -controllerPolicy delta => the existing artifact2Policy, opPolicy, op2Policy become disabled as no
// policy type is readily available to host them until there is a host.
verifyActivePoliciesWithDisables(
- List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy),
- List.of(opPolicy.getIdentifier(), op2Policy.getIdentifier()));
+ List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy),
+ List.of(opPolicy.getIdentifier(), op2Policy.getIdentifier()));
// Delta: -opPolicy, -op2Policy, -controller2Policy, -valPolicy, -artifact2Policy, -unvalPolicy
- // from deltas, -opPolicy and -op2Policy undeploys will fail since there is not controller with that
+ // from deltas, -opPolicy and -op2Policy undeploys will fail since there is no controller with that
// policy type supported
assertFalse(fsm.update(getPdpUpdate(List.of(),
- List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy))));
+ List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy))));
assertThatIllegalArgumentException().isThrownBy(() -> PolicyControllerConstants.getFactory().get("lifecycle"));
assertThatIllegalArgumentException().isThrownBy(() -> PolicyControllerConstants.getFactory().get("foo"));
assertEquals(0, PolicyControllerConstants.getFactory().inventory().size());
- verifyDeploy(List.of(), 17, 16, 1, 16, 14, 2);
+ verifyDeploy(List.of());
fsm.shutdown();
}
return update;
}
- protected void deltaUpdate(List<ToscaPolicy> deploy, List<ToscaPolicy> undeploy, List<ToscaPolicy> active,
- long deployCount, long deploySuccess, long deployFail, long undeployCount, long undeploySuccess,
- long undeployFail) throws CoderException {
+ protected void deltaUpdate(List<ToscaPolicy> deploy, List<ToscaPolicy> undeploy, List<ToscaPolicy> active)
+ throws CoderException {
assertTrue(fsm.update(getPdpUpdate(deploy, undeploy)));
- verifyDeploy(active, deployCount, deploySuccess, deployFail, undeployCount, undeploySuccess, undeployFail);
+ verifyDeploy(active);
}
- private void verifyDeploy(List<ToscaPolicy> active, long deployCount, long deploySuccess, long deployFail,
- long undeployCount, long undeploySuccess, long undeployFail) throws CoderException {
+ private void verifyDeploy(List<ToscaPolicy> active) throws CoderException {
verifyActivePolicies(active);
}
assertTrue(PolicyControllerConstants.getFactory().get(controller).getDrools().isBrained());
for (ToscaPolicy policy : policies) {
assertEquals("ID: " + controller + ":" + policy.getIdentifier(), exists,
- PolicyControllerConstants.getFactory().get(controller).getDrools().exists(policy));
+ PolicyControllerConstants.getFactory().get(controller).getDrools().exists(policy));
}
}
}
protected void verifyActivePoliciesWithDisables(List<ToscaPolicy> testPolicies,
- List<ToscaConceptIdentifier> nativeDisables) throws CoderException {
+ List<ToscaConceptIdentifier> nativeDisables) throws CoderException {
// verify that each policy is tracked in the active lists
for (ToscaPolicy policy : testPolicies) {
assertTrue(policy.getIdentifier().toString(), fsm.getActivePolicies().contains(policy));
if (!nativeDisables.contains(policy.getIdentifier())) {
assertTrue(policy.getIdentifier().toString(),
- fsm.getPolicyTypesMap().containsKey(policy.getTypeIdentifier()));
+ fsm.getPolicyTypesMap().containsKey(policy.getTypeIdentifier()));
}
}
assertEquals(testPolicies.size(), fsm.getActivePolicies().size());
// verify that a controller exists for each controller policy
assertEquals(fsm.getNativeControllerPolicies(testPoliciesMap).size(),
- PolicyControllerConstants.getFactory().inventory().size());
+ PolicyControllerConstants.getFactory().inventory().size());
// verify that a brained controller with same application coordinates exist for
// each native artifact policy
String controllerName = artifactPolicy.getProperties().getController().getName();
assertTrue(PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained());
assertEquals(artifactPolicy.getProperties().getRulesArtifact().getGroupId(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().getGroupId());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().getGroupId());
assertEquals(artifactPolicy.getProperties().getRulesArtifact().getArtifactId(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().getArtifactId());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().getArtifactId());
assertEquals(artifactPolicy.getProperties().getRulesArtifact().getVersion(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().getVersion());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().getVersion());
}
}
protected void verifyNonNativePolicy(ToscaPolicy testPolicy, List<ToscaConceptIdentifier> nativeDisables)
- throws CoderException {
+ throws CoderException {
List<ToscaPolicy> nativeArtifactPolicies =
- fsm.getNativeArtifactPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
+ fsm.getNativeArtifactPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
List<ToscaPolicy> nativeControllerPolicies =
- fsm.getNativeControllerPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
+ fsm.getNativeControllerPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
String controllerName = (String) testPolicy.getProperties().get("controllerName");
for (ToscaPolicy nativePolicy : nativeArtifactPolicies) {
NativeArtifactPolicy artifactPolicy =
- fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
+ fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
String artifactControllerName = artifactPolicy.getProperties().getController().getName();
// brained controller check
assertTrue(artifactControllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(artifactControllerName).getDrools().isBrained());
+ PolicyControllerConstants.getFactory().get(artifactControllerName).getDrools().isBrained());
// non native tosca policy as a fact in drools
if (PolicyControllerConstants.getFactory().get(artifactControllerName).getPolicyTypes()
- .contains(testPolicy.getTypeIdentifier())) {
+ .contains(testPolicy.getTypeIdentifier())) {
assertTrue(artifactControllerName + ":" + testPolicy.getIdentifier(), PolicyControllerConstants
- .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
+ .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
} else {
assertFalse(artifactControllerName + ":" + testPolicy.getIdentifier(), PolicyControllerConstants
- .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
+ .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
}
// there should always be a controller policy for each artifact policy
// verify the policy is present as a fact if there is matching artifact policy
List<NativeArtifactPolicy> candidateNativeArtifactPolicies =
- getNativeArtifactPolicies(nativeArtifactPolicies, controllerName);
+ getNativeArtifactPolicies(nativeArtifactPolicies, controllerName);
if (candidateNativeArtifactPolicies.size() == 1) {
assertTrue(controllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained());
assertTrue(controllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().exists(testPolicy));
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().exists(testPolicy));
// verify that the other brained controllers don't have this non-native policy
// at this point the only valid possibility is that there is no native artifact policies
assertTrue("There is more than 1 native artifact policy for " + controllerName,
- candidateNativeArtifactPolicies.isEmpty());
+ candidateNativeArtifactPolicies.isEmpty());
}
protected List<NativeArtifactPolicy> getNativeArtifactPoliciesBut(List<ToscaPolicy> nativePolicies,
- String controllerName) {
+ String controllerName) {
return nativePolicies.stream().map(nativePolicy -> {
try {
return fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
throw new RuntimeException(nativePolicy.getIdentifier().toString(), ex);
}
}).filter(nativeArtifactPolicy -> !controllerName
- .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
+ .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
}
protected List<NativeArtifactPolicy> getNativeArtifactPolicies(List<ToscaPolicy> nativePolicies,
- String controllerName) {
+ String controllerName) {
return nativePolicies.stream().map(nativePolicy -> {
try {
return fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
throw new RuntimeException(nativePolicy.getIdentifier().toString(), ex);
}
}).filter(nativeArtifactPolicy -> controllerName
- .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
+ .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
}
protected List<ControllerPolicy> getNativeControllerPolicies(List<ToscaPolicy> nativePolicies,
- String controllerName) {
+ String controllerName) {
return nativePolicies.stream().map(controllerPolicy -> {
try {
return fsm.getDomainMaker().convertTo(controllerPolicy, ControllerPolicy.class);
* ONAP
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 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.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
*/
@Before
public void setUp() {
- when(droolsProviders.getList()).thenReturn(Arrays.asList(prov1, prov2));
+ when(droolsProviders.getList()).thenReturn(List.of(prov1, prov2));
when(coderMgr.isDecodingSupported(GROUP, ARTIFACT, TOPIC)).thenReturn(true);
when(coderMgr.decode(GROUP, ARTIFACT, TOPIC, EVENT_TEXT)).thenReturn(EVENT);
when(kieSess.getFactCount()).thenReturn(FACT_COUNT);
- when(kieSess.getFactHandles()).thenReturn(Arrays.asList(fact1, fact2, factex, fact3));
- when(kieSess.getFactHandles(any())).thenReturn(Arrays.asList(fact1, fact3));
+ when(kieSess.getFactHandles()).thenReturn(List.of(fact1, fact2, factex, fact3));
+ when(kieSess.getFactHandles(any())).thenReturn(List.of(fact1, fact3));
when(kieSess.getKieBase()).thenReturn(kieBase);
when(kieSess.getQueryResults(QUERY, PARM1, PARM2)).thenReturn(queryResults);
when(kieSess.getObject(fact3)).thenReturn(FACT3_OBJECT);
when(kieSess.getObject(factex)).thenThrow(RUNTIME_EX);
- when(kieBase.getKiePackages()).thenReturn(Arrays.asList(pkg1, pkg2));
+ when(kieBase.getKiePackages()).thenReturn(List.of(pkg1, pkg2));
- when(pkg1.getQueries()).thenReturn(Arrays.asList(query3));
- when(pkg2.getQueries()).thenReturn(Arrays.asList(query2, query1));
+ when(pkg1.getQueries()).thenReturn(List.of(query3));
+ when(pkg2.getQueries()).thenReturn(List.of(query2, query1));
when(query1.getName()).thenReturn(QUERY);
when(query2.getName()).thenReturn(QUERY2);
- when(queryResults.iterator()).thenReturn(Arrays.asList(row1, row2).iterator());
+ when(queryResults.iterator()).thenReturn(List.of(row1, row2).iterator());
when(row1.get(ENTITY)).thenReturn(FACT1_OBJECT);
when(row2.get(ENTITY)).thenReturn(FACT3_OBJECT);
when(sess2.getFullName()).thenReturn(FULL_SESSION2);
when(container.getClassLoader()).thenReturn(CLASS_LOADER);
- when(container.getPolicySessions()).thenReturn(Arrays.asList(sess1, sess2));
+ when(container.getPolicySessions()).thenReturn(List.of(sess1, sess2));
when(container.insertAll(EVENT)).thenReturn(true);
when(decoder1.getTopic()).thenReturn(TOPIC);
when(encoder1.getTopic()).thenReturn(TOPIC);
when(encoder2.getTopic()).thenReturn(TOPIC2);
- decoders = Arrays.asList(decoder1, decoder2);
- encoders = Arrays.asList(encoder1, encoder2);
+ decoders = List.of(decoder1, decoder2);
+ encoders = List.of(encoder1, encoder2);
when(decoder1.getCustomGsonCoder()).thenReturn(gson1);
when(encoder2.getCustomGsonCoder()).thenReturn(gson2);
when(filter2.getCodedClass()).thenReturn(Integer.class.getName());
when(filter2.getFilter()).thenReturn(jsonFilter2);
- when(decoder1.getCoderFilters()).thenReturn(Arrays.asList(filter1a, filter1b));
+ when(decoder1.getCoderFilters()).thenReturn(List.of(filter1a, filter1b));
when(decoder2.getCoderFilters()).thenReturn(Collections.emptyList());
when(encoder1.getCoderFilters()).thenReturn(Collections.emptyList());
- when(encoder2.getCoderFilters()).thenReturn(Arrays.asList(filter2));
+ when(encoder2.getCoderFilters()).thenReturn(List.of(filter2));
when(sink.getTopic()).thenReturn(TOPIC);
when(sink.send(EVENT_TEXT)).thenReturn(true);
// unknown class
drools = new MyDrools(GROUP, ARTIFACT, VERSION, null, null) {
@Override
- protected boolean isClass(String className) {
- return false;
+ protected boolean isNotAClass(String className) {
+ return true;
}
};
assertFalse(drools.ownsCoder(String.class, hc));
assertEquals(GROUP, drools.getGroupId());
assertEquals(CLASS_LOADER_HASHCODE, drools.getModelClassLoaderHash());
assertSame(container, drools.getContainer());
- assertEquals(Arrays.asList(sess1, sess2), drools.getSessions());
+ assertEquals(List.of(sess1, sess2), drools.getSessions());
// test junit methods - need a controller with fewer overrides
drools = new MavenDroolsController(GROUP, ARTIFACT, VERSION, null, null) {
@Test
public void testGetBaseDomainNames() {
KieContainer kiecont = mock(KieContainer.class);
- when(kiecont.getKieBaseNames()).thenReturn(Arrays.asList("kieA", "kieB"));
+ when(kiecont.getKieBaseNames()).thenReturn(List.of("kieA", "kieB"));
when(container.getKieContainer()).thenReturn(kiecont);
assertEquals("[kieA, kieB]", drools.getBaseDomainNames().toString());