Migrated tests to JUnit 5 (#1619)

* Migrated tests to JUnit 5

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2020-09-04 08:23:00 +02:00 committed by GitHub
parent 7eb6d39ae0
commit bee8206853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,16 +13,17 @@
package org.openhab.core.config.discovery; package org.openhab.core.config.discovery;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsMapContaining.hasEntry; import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.junit.Assert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.ThingUID;
@ -51,7 +52,7 @@ public class DiscoveryResultBuilderTest {
private DiscoveryResultBuilder builder; private DiscoveryResultBuilder builder;
private DiscoveryResult discoveryResult; private DiscoveryResult discoveryResult;
@Before @BeforeEach
public void setup() { public void setup() {
builder = DiscoveryResultBuilder.create(THING_UID).withThingType(THING_TYPE_UID).withProperties(properties) builder = DiscoveryResultBuilder.create(THING_UID).withThingType(THING_TYPE_UID).withProperties(properties)
.withRepresentationProperty(KEY1).withLabel("Test"); .withRepresentationProperty(KEY1).withLabel("Test");
@ -85,15 +86,14 @@ public class DiscoveryResultBuilderTest {
assertThat(otherDiscoveryResult.getBridgeUID(), is(BRIDGE_UID)); assertThat(otherDiscoveryResult.getBridgeUID(), is(BRIDGE_UID));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testDiscoveryResultBuilderWithBridge() { public void testDiscoveryResultBuilderWithBridge() {
@SuppressWarnings("unused") assertThrows(IllegalArgumentException.class, () -> DiscoveryResultBuilder
DiscoveryResult otherDiscoveryResult = DiscoveryResultBuilder .create(new ThingUID(THING_TYPE_UID, "otherThingId")).withBridge(BRIDGE_UID).build());
.create(new ThingUID(THING_TYPE_UID, "otherThingId")).withBridge(BRIDGE_UID).build();
} }
@Test @Test
@Ignore @Disabled
public void subsequentBuildsCreateIndependentDiscoveryResults() { public void subsequentBuildsCreateIndependentDiscoveryResults() {
DiscoveryResult otherDiscoveryResult = builder.withLabel("Second Test").withProperties(Collections.emptyMap()) DiscoveryResult otherDiscoveryResult = builder.withLabel("Second Test").withProperties(Collections.emptyMap())
.build(); .build();