Skip to content
Permalink
Browse files

Migrate first test to Junit Jupiter

  • Loading branch information...
schnatterer committed Apr 1, 2018
1 parent d4b0bb1 commit 6197ae9f2d0283026fa35e6db9296e69eeb2bab2
Showing with 46 additions and 19 deletions.
  1. +19 −18 commons-lib/src/test/java/info/schnatterer/colander/PropertiesTest.java
  2. +27 −1 pom.xml
@@ -27,56 +27,57 @@
import net.fortuna.ical4j.model.component.VEvent;
import net.fortuna.ical4j.model.property.Description;
import net.fortuna.ical4j.model.property.Summary;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Optional;

public class PropertiesTest {
CalendarComponent calendarComponent = new VEvent();
import static org.junit.jupiter.api.Assertions.assertEquals;

class PropertiesTest {
private CalendarComponent calendarComponent = new VEvent();

@Test
public void getProperty() throws Exception {
void getProperty() throws Exception {
Summary expectedSummary = new Summary("value");
calendarComponent.getProperties().add(expectedSummary);
Assert.assertEquals(expectedSummary, Properties.getSummary(calendarComponent).orElse(null));
assertEquals(expectedSummary, Properties.getSummary(calendarComponent).orElse(null));
}

@Test
public void getPropertyNoSummary() throws Exception {
Assert.assertEquals(Optional.empty(), Properties.getSummary(calendarComponent));
void getPropertyNoSummary() throws Exception {
assertEquals(Optional.empty(), Properties.getSummary(calendarComponent));
}

@Test
public void getPropertyValue() throws Exception {
void getPropertyValue() throws Exception {
String expectedValue = "val";
calendarComponent.getProperties().add(new Summary(expectedValue));
Assert.assertEquals(expectedValue, Properties.getSummaryValue(calendarComponent).orElse(null));
assertEquals(expectedValue, Properties.getSummaryValue(calendarComponent).orElse(null));
}

@Test
public void getPropertyValueNoSummary() throws Exception {
Assert.assertEquals(Optional.empty(), Properties.getSummaryValue(calendarComponent));
void getPropertyValueNoSummary() throws Exception {
assertEquals(Optional.empty(), Properties.getSummaryValue(calendarComponent));
}

@Test
public void getPropertyValueNoSummaryValue() throws Exception {
void getPropertyValueNoSummaryValue() throws Exception {
Summary expectedSummary = new Summary(null);
calendarComponent.getProperties().add(expectedSummary);
Assert.assertEquals(Optional.empty(), Properties.getSummaryValue(calendarComponent));
assertEquals(Optional.empty(), Properties.getSummaryValue(calendarComponent));
}

@Test
public void getDescription() throws Exception {
void getDescription() throws Exception {
Description expectedDescription = new Description("value");
calendarComponent.getProperties().add(expectedDescription);
Assert.assertEquals(expectedDescription, Properties.getDescription(calendarComponent).orElse(null));
assertEquals(expectedDescription, Properties.getDescription(calendarComponent).orElse(null));
}

@Test
public void getDescriptionValue() throws Exception {
void getDescriptionValue() throws Exception {
String expectedValue = "val";
calendarComponent.getProperties().add(new Description(expectedValue));
Assert.assertEquals(expectedValue, Properties.getDescriptionValue(calendarComponent).orElse(null));
assertEquals(expectedValue, Properties.getDescriptionValue(calendarComponent).orElse(null));
}
}
28 pom.xml
@@ -46,6 +46,7 @@
<slf4j.version>1.7.22</slf4j.version>
<logback.version>1.1.8</logback.version>
<jacoco.version>0.7.8</jacoco.version>
<junit5.version>5.1.0</junit5.version>
</properties>

<modules>
@@ -74,10 +75,12 @@
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>

<!-- JUnit 4 dependencies -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.1.0</version>
<version>${junit5.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
@@ -89,10 +92,19 @@
<artifactId>hamcrest-junit</artifactId>
<version>2.0.0.0</version>
</dependency>

<!-- Junit 5 dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

<dependencies>
<!-- JUnit 4 dependencies -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
@@ -108,6 +120,13 @@
<artifactId>hamcrest-junit</artifactId>
<scope>test</scope>
</dependency>

<!-- Junit 5 dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
@@ -187,6 +206,13 @@
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

0 comments on commit 6197ae9

Please sign in to comment.
You can’t perform that action at this time.