Skip to content

Commit

Permalink
Merge pull request #514 from gbalderas/503_migrate_tests_to_junit5
Browse files Browse the repository at this point in the history
#503 migrate tests to junit5 #504
  • Loading branch information
manuel-mauky authored Sep 20, 2017
2 parents 5c1d14c + 958fb83 commit 48ea2cf
Show file tree
Hide file tree
Showing 92 changed files with 752 additions and 676 deletions.
6 changes: 5 additions & 1 deletion examples/books-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import de.saxsys.mvvmfx.examples.books.backend.Error;
import de.saxsys.mvvmfx.examples.books.backend.Book;
import de.saxsys.mvvmfx.examples.books.backend.LibraryService;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -19,7 +19,7 @@ public class MainViewModelTest {
private MainViewModel viewModel;
private LibraryService libraryService;

@Before
@BeforeEach
public void setup() {
libraryService = mock(LibraryService.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.saxsys.mvvmfx.examples.books.backend;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.List;

Expand All @@ -18,7 +18,7 @@ public class LibraryServiceMockTest {

private Book theMetamorphosis;

@Before
@BeforeEach
public void setup() {
libraryService = new LibraryServiceMockImpl();

Expand Down
4 changes: 2 additions & 2 deletions examples/contacts-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package de.saxsys.mvvmfx.examples.contacts;

import de.saxsys.mvvmfx.examples.contacts.App;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.testfx.api.FxRobot;
import org.testfx.api.FxToolkit;

import static org.testfx.api.FxAssert.verifyThat;
import static org.testfx.matcher.control.TableViewMatchers.hasTableCell;

@Ignore
@Disabled
public class AppTestFxIT extends FxRobot {

@Before
@BeforeEach
public void setupApp() throws Exception {

FxToolkit.registerPrimaryStage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import de.saxsys.mvvmfx.examples.contacts.model.countries.CountrySelector;
import javafx.application.Platform;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand All @@ -16,12 +16,12 @@

import static eu.lestard.assertj.javafx.api.Assertions.assertThat;

public abstract class AbstractCountrySelectorTest {
public interface CountrySelectorInterfaceTest {

protected abstract CountrySelector getCountrySelector();
CountrySelector getCountrySelector();

@Test
public void testLoadSubdivisions() throws Exception {
default void testLoadSubdivisions() throws Exception {
CountrySelector countrySelector = getCountrySelector();
runBlocked(countrySelector::init);

Expand All @@ -47,7 +47,7 @@ public void testLoadSubdivisions() throws Exception {
}

@Test
public void testLoadCountries() throws InterruptedException, ExecutionException, TimeoutException {
default void testLoadCountries() throws InterruptedException, ExecutionException, TimeoutException {
CountrySelector countrySelector = getCountrySelector();

runBlocked(countrySelector::init);
Expand Down Expand Up @@ -86,7 +86,7 @@ public void testLoadCountries() throws InterruptedException, ExecutionException,
assertThat(countrySelector.subdivisionLabel()).hasNullValue();
}

protected void runBlocked(Runnable function) {
default void runBlocked(Runnable function) {
CompletableFuture<Boolean> blocker = new CompletableFuture<>();

getCountrySelector().inProgressProperty().addListener((obs, oldV, newV) -> {
Expand All @@ -104,15 +104,15 @@ protected void runBlocked(Runnable function) {
}
}

protected Country getCountryByName(List<Country> countries, String name) {
default Country getCountryByName(List<Country> countries, String name) {
return countries.stream().filter(country -> country.getName().equals(name)).findFirst().orElse(null);
}

protected List<String> getSubdivisionNames(List<Subdivision> subdivisions) {
default List<String> getSubdivisionNames(List<Subdivision> subdivisions) {
return subdivisions.stream().map(Subdivision::getName).collect(Collectors.toList());
}

protected List<String> getCountryNames(List<Country> countries) {
default List<String> getCountryNames(List<Country> countries) {
return countries.stream().map(Country::getName).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
package de.saxsys.mvvmfx.examples.contacts.model.countries;

import de.saxsys.mvvmfx.examples.contacts.model.Country;
import de.saxsys.mvvmfx.testingutils.jfxrunner.JfxRunner;
import de.saxsys.mvvmfx.testingutils.JfxToolkitExtension;
import org.datafx.reader.converter.XmlConverter;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(JfxRunner.class)
public class DataFxCountrySelectorIntegrationTest extends AbstractCountrySelectorTest {
@ExtendWith(JfxToolkitExtension.class)
public class DataFxCountrySelectorIntegrationTest implements CountrySelectorInterfaceTest {

private CountrySelector countrySelector;


@Override
protected CountrySelector getCountrySelector() {
@Override public CountrySelector getCountrySelector() {
return countrySelector;
}

@Before
@BeforeEach
public void setup() {
countrySelector = new DataFxCountrySelector();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package de.saxsys.mvvmfx.examples.contacts.model.countries;

import de.saxsys.mvvmfx.testingutils.jfxrunner.JfxRunner;
import org.junit.Before;
import org.junit.runner.RunWith;
import de.saxsys.mvvmfx.testingutils.JfxToolkitExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;

@RunWith(JfxRunner.class)
public class DomCountrySelectorIntegrationTest extends AbstractCountrySelectorTest {
@ExtendWith(JfxToolkitExtension.class)
public class DomCountrySelectorIntegrationTest implements CountrySelectorInterfaceTest {

private CountrySelector countrySelector;

@Before
@BeforeEach
public void setup(){
countrySelector = new DomCountrySelector();
}


@Override
protected CountrySelector getCountrySelector() {
@Override public CountrySelector getCountrySelector() {
return countrySelector;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package de.saxsys.mvvmfx.examples.contacts.model.countries;

import de.saxsys.mvvmfx.examples.contacts.model.countries.AbstractCountrySelectorTest;
import de.saxsys.mvvmfx.examples.contacts.model.countries.CountrySelector;
import de.saxsys.mvvmfx.examples.contacts.model.countries.JAXBCountrySelector;
import de.saxsys.mvvmfx.testingutils.jfxrunner.JfxRunner;
import org.junit.Before;
import org.junit.runner.RunWith;
import de.saxsys.mvvmfx.testingutils.JfxToolkitExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;

@RunWith(JfxRunner.class)
public class JAXBCountrySelectorIntegrationTest extends AbstractCountrySelectorTest {
@ExtendWith(JfxToolkitExtension.class)
public class JAXBCountrySelectorIntegrationTest implements CountrySelectorInterfaceTest {

private CountrySelector countrySelector;

@Before
@BeforeEach
public void setup() {
countrySelector = new JAXBCountrySelector();
}

@Override
protected CountrySelector getCountrySelector() {
@Override public CountrySelector getCountrySelector() {
return countrySelector;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import de.saxsys.mvvmfx.examples.contacts.util.CentralClock;
import de.saxsys.mvvmfx.utils.validation.ValidationStatus;
Expand All @@ -24,7 +24,7 @@ public class BirthdayValidatorTest {
private ValidationStatus result;
private ObjectProperty<LocalDate> value = new SimpleObjectProperty<>();

@Before
@BeforeEach
public void setup() {
ZonedDateTime now = ZonedDateTime
.of(LocalDate.of(2014, Month.JANUARY, 1), LocalTime.of(0, 0), ZoneId.systemDefault());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import de.saxsys.mvvmfx.utils.validation.ValidationStatus;

Expand All @@ -17,7 +17,7 @@ public class EmailAddressValidatorTest {
private ValidationStatus result;
private StringProperty value = new SimpleStringProperty();

@Before
@BeforeEach
public void setup() {
Validator validator = new EmailValidator(value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import de.saxsys.mvvmfx.utils.validation.ValidationStatus;

Expand All @@ -17,7 +17,7 @@ public class PhoneNumberValidatorTest {
private ValidationStatus result;
private StringProperty value = new SimpleStringProperty();

@Before
@BeforeEach
public void setup() {
Validator validator = new PhoneValidator(value, "error message");

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

import javafx.beans.property.ReadOnlyStringProperty;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class AboutViewModelTest {

Expand All @@ -25,7 +25,7 @@ public class AboutViewModelTest {
private Consumer<String> onLinkClickedHandler;

@SuppressWarnings("unchecked")
@Before
@BeforeEach
public void setup() {
viewModel = new AboutViewModel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ListResourceBundle;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -39,7 +39,7 @@ public class AddressFormViewModelTest {

private ContactDialogScope scope;

@Before
@BeforeEach
public void setup() {
availableCountries.addAll(germany, austria);

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

import de.saxsys.mvvmfx.examples.contacts.ui.scopes.ContactDialogScope;
import javafx.beans.property.BooleanProperty;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static eu.lestard.assertj.javafx.api.Assertions.assertThat;

Expand All @@ -16,7 +16,7 @@ public class ContactDialogViewModelTest {
private BooleanProperty contactFormValid;
private BooleanProperty addressFormValid;

@Before
@BeforeEach
public void setup() {
scope = new ContactDialogScope();
contactFormValid = scope.contactFormValidProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import de.saxsys.mvvmfx.examples.contacts.ui.contactform.ContactFormViewModel;
import de.saxsys.mvvmfx.testingutils.GCVerifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static eu.lestard.assertj.javafx.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -12,7 +12,7 @@ public class ContactFormViewModelTest {

private ContactFormViewModel viewModel;

@Before
@BeforeEach
public void setup() {
viewModel = new ContactFormViewModel();
}
Expand Down
Loading

0 comments on commit 48ea2cf

Please sign in to comment.