Reenable org.openhab.core.automation.integration.tests (#1061)

- Reenable org.openhab.core.automation.integration.tests (#1061)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2019-10-01 15:49:43 +02:00 committed by Christoph Weitkamp
parent 8e3a521083
commit 871517008e
5 changed files with 91 additions and 185 deletions

View File

@ -1,95 +1,48 @@
-include: ../itest-common.bndrun
Bundle-SymbolicName: ${project.artifactId}
Fragment-Host: org.openhab.core.automation.integration
-runrequires: bnd.identity;id='org.openhab.core.automation.integration.tests'
# We would like to use the "volatile" storage only
-runblacklist: \
bnd.identity;id='org.openhab.core.storage.json',\
bnd.identity;id='org.openhab.core.storage.mapdb'
#
# done
#
-runbundles: \
ch.qos.logback.classic;version='[1.2.0,1.2.1)',\
ch.qos.logback.core;version='[1.2.0,1.2.1)',\
com.google.gson;version='[2.7.0,2.7.1)',\
com.google.guava;version='[15.0.0,15.0.1)',\
com.google.inject;version='[3.0.0,3.0.1)',\
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
com.google.gson;version='[2.8.2,2.8.3)',\
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
joda-time;version='[2.9.2,2.9.3)',\
log4j;version='[1.2.17,1.2.18)',\
org.antlr.runtime;version='[3.2.0,3.2.1)',\
org.apache.commons.collections;version='[3.2.1,3.2.2)',\
org.apache.commons.exec;version='[1.1.0,1.1.1)',\
org.apache.commons.io;version='[2.2.0,2.2.1)',\
org.apache.commons.lang;version='[2.6.0,2.6.1)',\
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.10,2.1.11)',\
org.apache.servicemix.bundles.commons-codec;version='[1.3.0,1.3.1)',\
org.apache.servicemix.bundles.commons-httpclient;version='[3.1.0,3.1.1)',\
org.apache.xbean.bundleutils;version='[4.6.0,4.6.1)',\
org.apache.xbean.finder;version='[4.6.0,4.6.1)',\
org.eclipse.emf.common;version='[2.12.0,2.12.1)',\
org.eclipse.emf.ecore;version='[2.12.0,2.12.1)',\
org.eclipse.emf.ecore.xmi;version='[2.12.0,2.12.1)',\
org.eclipse.equinox.common;version='[3.8.0,3.8.1)',\
org.apache.servicemix.specs.activation-api-1.1;version='[2.9.0,2.9.1)',\
org.apache.servicemix.specs.annotation-api-1.3;version='[1.3.0,1.3.1)',\
org.apache.servicemix.specs.jaxb-api-2.2;version='[2.9.0,2.9.1)',\
org.apache.servicemix.specs.stax-api-1.2;version='[2.9.0,2.9.1)',\
org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\
org.eclipse.jetty.client;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.http;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.io;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.proxy;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.security;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.server;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.servlet;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.util;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.websocket.api;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.websocket.client;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.websocket.common;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.xml;version='[9.4.11,9.4.12)',\
org.eclipse.xtend.lib;version='[2.14.0,2.14.1)',\
org.eclipse.xtend.lib.macro;version='[2.14.0,2.14.1)',\
org.eclipse.xtext;version='[2.14.0,2.14.1)',\
org.eclipse.xtext.common.types;version='[2.14.0,2.14.1)',\
org.eclipse.xtext.util;version='[2.14.0,2.14.1)',\
org.eclipse.xtext.xbase;version='[2.14.0,2.14.1)',\
org.eclipse.xtext.xbase.lib;version='[2.14.0,2.14.1)',\
org.glassfish.hk2.external.aopalliance-repackaged;version='[2.4.0,2.4.1)',\
org.glassfish.hk2.external.javax.inject;version='[2.4.0,2.4.1)',\
org.objectweb.asm;version='[6.1.1,6.1.2)',\
org.objectweb.asm.commons;version='[6.1.1,6.1.2)',\
org.objectweb.asm.tree;version='[6.1.1,6.1.2)',\
org.openhab.core.compat1x;version='[2.5.0,2.5.1)',\
org.ops4j.pax.swissbox.optional.jcl;version='[1.8.2,1.8.3)',\
org.ops4j.pax.web.pax-web-api;version='[7.2.3,7.2.4)',\
org.ops4j.pax.web.pax-web-jetty;version='[7.2.3,7.2.4)',\
org.ops4j.pax.web.pax-web-runtime;version='[7.2.3,7.2.4)',\
org.ops4j.pax.web.pax-web-spi;version='[7.2.3,7.2.4)',\
org.osgi.service.event;version='[1.4.0,1.4.1)',\
slf4j.api;version='[1.7.21,1.7.22)',\
tec.uom.lib.uom-lib-common;version='[1.0.2,1.0.3)',\
tec.uom.se;version='[1.0.8,1.0.9)',\
osgi.enroute.hamcrest.wrapper;version='[1.3.0,1.3.1)',\
osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)',\
org.openhab.core;version='[2.5.0,2.5.1)',\
org.openhab.core.audio;version='[2.5.0,2.5.1)',\
org.openhab.core.compat1x.tests;version='[2.5.0,2.5.1)',\
org.openhab.core.automation.integration.tests;version='[2.5.0,2.5.1)',\
org.openhab.core.automation;version='[2.5.0,2.5.1)',\
org.openhab.core.config.core;version='[2.5.0,2.5.1)',\
org.openhab.core.io.console;version='[2.5.0,2.5.1)',\
org.openhab.core.io.http;version='[2.5.0,2.5.1)',\
org.openhab.core.io.net;version='[2.5.0,2.5.1)',\
org.openhab.core.model.core;version='[2.5.0,2.5.1)',\
org.openhab.core.model.item;version='[2.5.0,2.5.1)',\
org.openhab.core.model.persistence;version='[2.5.0,2.5.1)',\
org.openhab.core.model.script;version='[2.5.0,2.5.1)',\
org.openhab.core.model.script.runtime;version='[2.5.0,2.5.1)',\
org.openhab.core.model.sitemap;version='[2.5.0,2.5.1)',\
org.openhab.core.persistence;version='[2.5.0,2.5.1)',\
org.openhab.core.scheduler;version='[2.5.0,2.5.1)',\
org.openhab.core.test;version='[2.5.0,2.5.1)',\
org.openhab.core.thing;version='[2.5.0,2.5.1)',\
org.openhab.core.transform;version='[2.5.0,2.5.1)',\
org.openhab.core.ui;version='[2.5.0,2.5.1)',\
org.openhab.core.voice;version='[2.5.0,2.5.1)',\
org.openhab.core.model.persistence.runtime;version='[2.5.0,2.5.1)',\
org.openhab.core.model.rule;version='[2.5.0,2.5.1)',\
org.openhab.core.model.thing;version='[2.5.0,2.5.1)',\
org.openhab.core.storage.json;version='[2.5.0,2.5.1)'
org.openhab.core;version='[2.5.0,2.5.1)',\
org.osgi.service.event;version='[1.4.0,1.4.1)',\
osgi.enroute.hamcrest.wrapper;version='[1.3.0,1.3.1)',\
osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)',\
slf4j.api;version='[1.7.25,1.7.26)',\
tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\
tec.uom.se;version='[1.0.10,1.0.11)'

View File

@ -21,7 +21,7 @@ import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.common.registry.ProviderChangeListener;
import org.eclipse.smarthome.core.events.Event;
@ -72,7 +72,7 @@ import org.slf4j.LoggerFactory;
*/
public class AutomationIntegrationJsonTest extends JavaOSGiTest {
final Logger logger = LoggerFactory.getLogger(AutomationIntegrationJsonTest.class);
private final Logger logger = LoggerFactory.getLogger(AutomationIntegrationJsonTest.class);
private EventPublisher eventPublisher;
private ItemRegistry itemRegistry;
private RuleRegistry ruleRegistry;
@ -92,14 +92,15 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
getService(ItemRegistry.class);
@NonNullByDefault
ItemProvider itemProvider = new ItemProvider() {
@Override
public void addProviderChangeListener(@NonNull ProviderChangeListener<@NonNull Item> listener) {
public void addProviderChangeListener(ProviderChangeListener<Item> listener) {
}
@Override
public @NonNull Collection<@NonNull Item> getAll() {
public Collection<Item> getAll() {
HashSet<Item> items = new HashSet<>();
items.add(new SwitchItem("myMotionItem"));
items.add(new SwitchItem("myPresenceItem"));
@ -117,17 +118,18 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
}
@Override
public void removeProviderChangeListener(@NonNull ProviderChangeListener<@NonNull Item> listener) {
public void removeProviderChangeListener(ProviderChangeListener<Item> listener) {
}
};
registerService(itemProvider);
registerVolatileStorageService();
@NonNullByDefault
EventSubscriber ruleEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(RuleStatusInfoEvent.TYPE);
}
@ -137,9 +139,8 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
logger.info("RuleEvent: " + e.getTopic() + " --> " + e.getPayload());
System.out.println("RuleEvent: " + e.getTopic() + " --> " + e.getPayload());
public void receive(Event e) {
logger.info("RuleEvent: {} --> {}", e.getTopic(), e.getPayload());
if (e.getPayload().contains("RUNNING")) {
ruleEvent = e;
}
@ -251,11 +252,6 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
assertThat(trigger.get().getConfiguration().get("eventSource"), is("myMotionItem"));
assertThat(trigger.get().getConfiguration().get("eventTopic"), is("smarthome/items/*"));
assertThat(trigger.get().getConfiguration().get("eventTypes"), is("ItemStateEvent"));
// def condition1 = rule.conditions.find{it.id.equals("ItemStateConditionID")} as Condition
// assertThat(condition1, is(notNullValue())
// assertThat(condition1.typeUID, is("core.GenericEventCondition")
// assertThat(condition1.configuration.get("topic"), is("smarthome/items/myMotionItem/state")
// assertThat(condition1.configuration.get("payload"), is(".*ON.*")
Optional<? extends Action> action = rule.getActions().stream()
.filter(a -> a.getId().equals("ItemPostCommandActionID")).findFirst();
assertThat(action.isPresent(), is(true));
@ -310,10 +306,11 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
// run the rule to check if the runtime rule has resolved module references and is executed successfully
EventPublisher eventPublisher = getService(EventPublisher.class);
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -323,7 +320,7 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("myLampItem")) {
itemEvent = e;
@ -357,10 +354,12 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
assertThat(myLampItem.getState(), is(UnDefType.NULL));
SwitchItem myMotionItem = (SwitchItem) itemRegistry.getItem("myMotionItem");
@NonNullByDefault
EventSubscriber eventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -370,7 +369,7 @@ public class AutomationIntegrationJsonTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().equals("smarthome/items/myLampItem/command")) {
itemEvent = e;

View File

@ -29,7 +29,7 @@ import java.util.Random;
import java.util.Set;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.config.core.ConfigDescriptionParameter;
import org.eclipse.smarthome.config.core.Configuration;
@ -50,7 +50,6 @@ import org.eclipse.smarthome.core.storage.StorageService;
import org.eclipse.smarthome.test.java.JavaOSGiTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openhab.core.automation.Action;
import org.openhab.core.automation.Condition;
@ -66,7 +65,6 @@ import org.openhab.core.automation.events.RuleAddedEvent;
import org.openhab.core.automation.events.RuleRemovedEvent;
import org.openhab.core.automation.events.RuleStatusInfoEvent;
import org.openhab.core.automation.events.RuleUpdatedEvent;
import org.openhab.core.automation.internal.module.handler.GenericEventTriggerHandler;
import org.openhab.core.automation.template.RuleTemplate;
import org.openhab.core.automation.template.RuleTemplateProvider;
import org.openhab.core.automation.template.Template;
@ -78,9 +76,6 @@ import org.openhab.core.automation.type.ModuleTypeRegistry;
import org.openhab.core.automation.type.TriggerType;
import org.openhab.core.automation.util.ModuleBuilder;
import org.openhab.core.automation.util.RuleBuilder;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -93,7 +88,7 @@ import org.slf4j.LoggerFactory;
*/
public class AutomationIntegrationTest extends JavaOSGiTest {
final Logger logger = LoggerFactory.getLogger(AutomationIntegrationTest.class);
private final Logger logger = LoggerFactory.getLogger(AutomationIntegrationTest.class);
private EventPublisher eventPublisher;
private ItemRegistry itemRegistry;
private RuleRegistry ruleRegistry;
@ -113,11 +108,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
ItemProvider itemProvider = new ItemProvider() {
@Override
public void addProviderChangeListener(@NonNull ProviderChangeListener<@NonNull Item> listener) {
public void addProviderChangeListener(ProviderChangeListener<Item> listener) {
}
@Override
public @NonNull Collection<@NonNull Item> getAll() {
public Collection<Item> getAll() {
Set<Item> items = new HashSet<>();
items.add(new SwitchItem("myMotionItem"));
items.add(new SwitchItem("myPresenceItem"));
@ -143,7 +138,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void removeProviderChangeListener(@NonNull ProviderChangeListener<@NonNull Item> listener) {
public void removeProviderChangeListener(ProviderChangeListener<Item> listener) {
}
};
@ -185,10 +180,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
public void assertThatARuleCanBeAddedUpdatedAndRemovedByTheApi() {
logger.info("assert that a rule can be added, updated and removed by the api");
@NonNullByDefault
EventSubscriber ruleEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Stream.of(RuleAddedEvent.TYPE, RuleRemovedEvent.TYPE, RuleUpdatedEvent.TYPE).collect(toSet());
}
@ -198,7 +194,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("RuleEvent: {}", e.getTopic());
ruleEvent = e;
}
@ -221,7 +217,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
// UPDATE
ruleEvent = null;
if (ruleAdded == null) {
throw new NullPointerException();
throw new AssertionError("ruleAdded is null");
}
Rule updatedRule = RuleBuilder.create(ruleAdded).withDescription("TestDescription").build();
Rule oldRule = ruleRegistry.update(updatedRule);
@ -289,10 +285,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
List<RuleStatusInfoEvent> ruleEvents = new ArrayList<>();
@NonNullByDefault
EventSubscriber ruleEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(RuleStatusInfoEvent.TYPE);
}
@ -302,7 +299,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("RuleEvent: {}", e.getTopic());
ruleEvents.add((RuleStatusInfoEvent) e);
}
@ -356,60 +353,6 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
assertThat(ruleEngine.getStatusInfo(rule.getUID()).getStatus(), is(RuleStatus.UNINITIALIZED));
}
@Test
public void assertThatARuleSwitchesFromIDLEtoUNINITIALIZEDifAModuleHandlerDisappearsAndBackToIDLEifItAppearsAgain()
throws BundleException {
logger.info(
"assert that a rule switches from IDLE to UNINITIALIZED if a moduleHanlder disappears and back to IDLE if it appears again");
Rule rule = createSimpleRule();
ruleRegistry.add(rule);
assertThat(ruleEngine.getStatusInfo(rule.getUID()).getStatus(), is(RuleStatus.IDLE));
Bundle moduleBundle = FrameworkUtil.getBundle(GenericEventTriggerHandler.class);
moduleBundle.stop();
waitForAssert(() -> {
logger.info("RuleStatus: {}", ruleEngine.getStatusInfo(rule.getUID()).getStatus());
assertThat(ruleEngine.getStatusInfo(rule.getUID()).getStatus(), is(RuleStatus.UNINITIALIZED));
}, 3000, 100);
moduleBundle.start();
ruleEngine.setEnabled(rule.getUID(), true);
waitForAssert(() -> {
logger.info("RuleStatus: {}", ruleEngine.getStatusInfo(rule.getUID()));
assertThat(ruleEngine.getStatusInfo(rule.getUID()).getStatus(), is(RuleStatus.IDLE));
}, 3000, 100);
}
@Test
@Ignore // this assumes that the sample.json bundle is started as part of the test, which is usually not the case
// (and we should not have a fixed dependency on it
public void assertThatAModuleTypesAndTemplatesAreDisappearedWhenTheProviderWasUninstalled() throws BundleException {
logger.info("assert that a module types and templates are disappeared when the provider was uninstalled");
waitForAssert(() -> {
logger.info("RuleStatus: {}", moduleTypeRegistry.get("SampleTrigger"));
assertThat(moduleTypeRegistry.get("SampleTrigger"), is(notNullValue()));
assertThat(moduleTypeRegistry.get("SampleCondition"), is(notNullValue()));
assertThat(moduleTypeRegistry.get("SampleAction"), is(notNullValue()));
assertThat(templateRegistry.get("SampleRuleTemplate"), is(notNullValue()));
}, 3000, 100);
for (Bundle bundle : bundleContext.getBundles()) {
if (bundle.getSymbolicName().equals("org.openhab.core.automation.sample.extension.json")) {
bundle.uninstall();
break;
}
}
waitForAssert(() -> {
logger.info("RuleStatus: {}", moduleTypeRegistry.get("SampleTrigger"));
assertThat(moduleTypeRegistry.get("SampleTrigger"), is(nullValue()));
assertThat(moduleTypeRegistry.get("SampleCondition"), is(nullValue()));
assertThat(moduleTypeRegistry.get("SampleAction"), is(nullValue()));
assertThat(templateRegistry.get("SampleRuleTemplate"), is(nullValue()));
}, 3000, 100);
}
@Test
public void assertThatARuleBasedOnACompositeModuleIsInitializedAndExecutedCorrectly() {
Map<String, Object> params = new HashMap<>();
@ -451,10 +394,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
EventPublisher eventPublisher = getService(EventPublisher.class);
eventPublisher.post(ItemEventFactory.createStateEvent("myPresenceItem3", OnOffType.ON));
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -464,7 +408,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("myLampItem3")) {
itemEvent = e;
@ -519,10 +463,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
Item myLampItem3 = itemRegistry.getItem("myLampItem3");
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -532,7 +477,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("myLampItem3")) {
itemEvent = e;
@ -576,10 +521,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
assertThat(ruleEngine.getStatusInfo(rule.getUID()).getStatus(), is(RuleStatus.IDLE));
}, 3000, 100);
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -589,7 +535,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("myLampItem3")) {
itemEvent = e;
@ -647,7 +593,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
Rule rule = RuleBuilder.create("myRule21" + new Random().nextInt() + "_COMPOSITE").withTriggers(triggers)
.withActions(actions).withName("RuleByJAVA_API_ChainedComposite").build();
logger.info("Rule created: " + rule.getUID());
logger.info("Rule created: {}", rule.getUID());
RuleRegistry ruleRegistry = getService(RuleRegistry.class);
ruleRegistry.add(rule);
@ -663,9 +609,10 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
// prepare the presenceItems state to be on to match the second condition of the rule
eventPublisher.post(ItemEventFactory.createStateEvent("myPresenceItem4", OnOffType.ON));
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -675,7 +622,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("myLampItem4")) {
itemEvent = e;
@ -714,7 +661,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
Rule rule = RuleBuilder.create("myRule21").withTriggers(triggers).withActions(actions)
.withName("RuleByJAVA_API").withTags("myRule21").build();
logger.info("Rule created: " + rule.getUID());
logger.info("Rule created: {}", rule.getUID());
ruleRegistry.add(rule);
ruleEngine.setEnabled(rule.getUID(), true);
@ -725,18 +672,20 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
public void assertThatARuleCanBeAddedByARuleProvider() {
logger.info("assert that a rule can be added by a ruleProvider");
Rule rule = createSimpleRule();
@NonNullByDefault
RuleProvider ruleProvider = new RuleProvider() {
@Override
public void addProviderChangeListener(@NonNull ProviderChangeListener<Rule> listener) {
public void addProviderChangeListener(ProviderChangeListener<Rule> listener) {
}
@Override
public @NonNull Collection<Rule> getAll() {
public Collection<Rule> getAll() {
return Collections.singleton(rule);
}
@Override
public void removeProviderChangeListener(@NonNull ProviderChangeListener<Rule> listener) {
public void removeProviderChangeListener(ProviderChangeListener<Rule> listener) {
}
};
@ -776,10 +725,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
ruleRegistry.add(templateRule);
assertThat(ruleRegistry.get(templateRule.getUID()), is(notNullValue()));
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -789,7 +739,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("templ_LampItem")) {
itemEvent = e;
@ -836,10 +786,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
assertThat(ruleEngine.getStatus(templateRule.getUID()), is(RuleStatus.IDLE));
});
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -849,7 +800,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("xtempl_LampItem")) {
itemEvent = e;
@ -906,32 +857,32 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void addProviderChangeListener(@NonNull ProviderChangeListener<RuleTemplate> listener) {
public void addProviderChangeListener(ProviderChangeListener<RuleTemplate> listener) {
}
@Override
public @NonNull Collection<RuleTemplate> getAll() {
public Collection<RuleTemplate> getAll() {
return Collections.singleton(template);
}
@Override
public void removeProviderChangeListener(@NonNull ProviderChangeListener<RuleTemplate> listener) {
public void removeProviderChangeListener(ProviderChangeListener<RuleTemplate> listener) {
}
};
ModuleTypeProvider moduleTypeProvider = new ModuleTypeProvider() {
@Override
public void addProviderChangeListener(@NonNull ProviderChangeListener<ModuleType> listener) {
public void addProviderChangeListener(ProviderChangeListener<ModuleType> listener) {
}
@Override
public @NonNull Collection<ModuleType> getAll() {
public Collection<ModuleType> getAll() {
return Stream.of(triggerType, actionType).collect(toSet());
}
@Override
public void removeProviderChangeListener(@NonNull ProviderChangeListener<ModuleType> listener) {
public void removeProviderChangeListener(ProviderChangeListener<ModuleType> listener) {
}
@Override
@ -1035,7 +986,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
Rule rule = RuleBuilder.create("myRule_" + random).withTriggers(triggers).withConditions(conditions)
.withActions(actions).withName("RuleByJAVA_API" + random).withTags("myRule_" + random).build();
logger.info("Rule created: " + rule.getUID());
logger.info("Rule created: {}", rule.getUID());
ruleRegistry.add(rule);
ruleEngine.setEnabled(rule.getUID(), true);
@ -1056,10 +1007,11 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
SwitchItem myMotionItem = (SwitchItem) itemRegistry.getItem("myPresenceItem5");
myMotionItem.setState(OnOffType.ON);
@NonNullByDefault
EventSubscriber itemEventHandler = new EventSubscriber() {
@Override
public @NonNull Set<@NonNull String> getSubscribedEventTypes() {
public Set<String> getSubscribedEventTypes() {
return Collections.singleton(ItemCommandEvent.TYPE);
}
@ -1069,7 +1021,7 @@ public class AutomationIntegrationTest extends JavaOSGiTest {
}
@Override
public void receive(@NonNull Event e) {
public void receive(Event e) {
logger.info("Event: {}", e.getTopic());
if (e.getTopic().contains("myLampItem5")) {
itemEvent = e;

View File

@ -40,12 +40,12 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("deprecation")
public class HostFragmentSupportTest extends JavaOSGiTest {
final Logger logger = LoggerFactory.getLogger(HostFragmentSupportTest.class);
private final Logger logger = LoggerFactory.getLogger(HostFragmentSupportTest.class);
private ModuleTypeRegistry moduleTypeRegistry;
private PackageAdmin pkgAdmin;
private final String EXT = ".jar";
private final String PATH = "src/test/resources/";
private final String PATH = "/";
private final String RESOURCES_TEST_BUNDLE_1 = "host-tb1";
private final String RESOURCES_TEST_BUNDLE_2 = "host-tb2";
private final String RESOURCES_TEST_BUNDLE_3 = "fragment-tb1";
@ -113,6 +113,7 @@ public class HostFragmentSupportTest extends JavaOSGiTest {
registerService(AutomationIntegrationJsonTest.VOLATILE_STORAGE_SERVICE);
}
@SuppressWarnings("null")
@Test
public void assertThatTheInstallationOfTheFragmentHostProvidesTheResourcesCorrectly() throws BundleException {
logger.info("asserting that the installation of the fragment-host provides the resources correctly");
@ -219,6 +220,7 @@ public class HostFragmentSupportTest extends JavaOSGiTest {
}
@SuppressWarnings("null")
@Test
public void assertThatTheUpdateOfTheFragmentHostProvidesTheResourcesCorrectly() throws BundleException {
logger.info("asserting that the update of the fragment-host provides the resources correctly");

View File

@ -24,7 +24,7 @@
<module>org.openhab.core.automation.module.timer.tests</module>
<module>org.openhab.core.automation.module.script.defaultscope.tests</module>
<module>org.openhab.core.automation.module.script.tests</module>
<!-- <module>org.openhab.core.automation.integration.tests</module> -->
<module>org.openhab.core.automation.integration.tests</module>
<module>org.openhab.core.binding.xml.tests</module>
<module>org.openhab.core.compat1x.tests</module>
<module>org.openhab.core.config.core.tests</module>