Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC of junit5/jupiter test migration #1195

Merged
merged 1 commit into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand All @@ -228,6 +233,12 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions service-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,23 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import org.eclipse.hono.config.ServiceConfigProperties;
import org.eclipse.hono.util.Constants;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
Expand All @@ -46,7 +46,7 @@ public class AbstractServiceBaseTest {
/**
* Sets up common mock objects used by the test cases.
*/
@Before
@BeforeEach
public void initMocks() {
eventBus = mock(EventBus.class);
vertx = mock(Vertx.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
package org.eclipse.hono.service;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.eclipse.hono.util.EventBusMessage;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
Expand All @@ -36,7 +37,7 @@ public class EventBusServiceTest {
/**
* Sets up the fixture.
*/
@BeforeClass
@BeforeAll
public static void setUp() {
service = new EventBusService<Object>() {

Expand Down Expand Up @@ -90,13 +91,13 @@ public void testValidType() {
.put("intValue", 42);

final String stringValue = EventBusService.getTypesafeValueForField(String.class, payload, "stringValue");
Assert.assertEquals("foo", stringValue);
assertEquals("foo", stringValue);

final Integer intValue = EventBusService.getTypesafeValueForField(Integer.class, payload, "intValue");
Assert.assertEquals(Integer.valueOf(42), intValue);
assertEquals(Integer.valueOf(42), intValue);

final Boolean booleanValue = EventBusService.getTypesafeValueForField(Boolean.class, payload, "booleanValue");
Assert.assertEquals(Boolean.TRUE, booleanValue);
assertEquals(Boolean.TRUE, booleanValue);
}

/**
Expand All @@ -107,10 +108,10 @@ public void testInvalidType() {
final JsonObject device = new JsonObject().put("device-id", "someValue");

final String stringValue = EventBusService.getTypesafeValueForField(String.class, device, "device-id");
Assert.assertEquals("someValue", stringValue);
assertEquals("someValue", stringValue);

final Integer intValue = EventBusService.getTypesafeValueForField(Integer.class, device, "device-id");
Assert.assertNull(intValue);
assertNull(intValue);
}

/**
Expand All @@ -121,7 +122,6 @@ public void testGetNull() {
final JsonObject device = new JsonObject().put("device-id", (String) null);

final String value = EventBusService.getTypesafeValueForField(String.class, device, "device-id");
Assert.assertNull(value);
assertNull(value);
}

}
Loading