Search in sources :

Example 11 with DynamicTest

use of org.junit.jupiter.api.DynamicTest in project tutorials by eugenp.

the class DynamicTests method dynamicUserTestCollection.

@TestFactory
public Stream<DynamicTest> dynamicUserTestCollection() {
    List<User> inputList = Arrays.asList(new User("john@yahoo.com", "John"), new User("ana@yahoo.com", "Ana"));
    Function<User, String> displayNameGenerator = (input) -> "Saving user: " + input;
    UserDAO userDAO = new UserDAO();
    ThrowingConsumer<User> testExecutor = (input) -> {
        userDAO.add(input);
        assertNotNull(userDAO.findOne(input.getEmail()));
    };
    return DynamicTest.stream(inputList.iterator(), displayNameGenerator, testExecutor);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) Stream(java.util.stream.Stream) TestFactory(org.junit.jupiter.api.TestFactory) Collection(java.util.Collection) UserDAO(com.stackify.daos.UserDAO) Assertions(org.junit.jupiter.api.Assertions) DynamicTest(org.junit.jupiter.api.DynamicTest) User(com.stackify.models.User) Function(java.util.function.Function) ThrowingConsumer(org.junit.jupiter.api.function.ThrowingConsumer) User(com.stackify.models.User) UserDAO(com.stackify.daos.UserDAO) TestFactory(org.junit.jupiter.api.TestFactory)

Example 12 with DynamicTest

use of org.junit.jupiter.api.DynamicTest in project acceptance-testing by Abhigulve.

the class EventHandler method TestInitiator.

@TestFactory
public Collection<DynamicTest> TestInitiator() {
    domManipulation.open(jr.getManupulatorBean().getUrl());
    String testName = jr.getManupulatorBean().getTestName();
    List<List<Map<String, String>>> list = jr.getManupulatorBean().getList();
    Collection<DynamicTest> dynamicTests = new ArrayList<>();
    for (int j = 0; j < list.size(); j++) {
        domManipulation.open(jr.getManupulatorBean().getUrl());
        List<Map<String, String>> testCase = list.get(j);
        int i = 0;
        for (int values = 1; values < testCase.size(); values++) {
            Map<String, String> map = testCase.get(values);
            domManipulation.action(map.get("id").toString(), map.get("value"), map.get("event").toUpperCase());
            i++;
            if (i == (testCase.size())) {
                DynamicTest dTest = DynamicTest.dynamicTest(testName, () -> domManipulation.testCaseAnalyser(map.get("id").toString(), map.get("condition").toUpperCase()));
                dynamicTests.add(dTest);
            }
        }
    }
    return dynamicTests;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) DynamicTest(org.junit.jupiter.api.DynamicTest) TestFactory(org.junit.jupiter.api.TestFactory)

Example 13 with DynamicTest

use of org.junit.jupiter.api.DynamicTest in project flue2ent by DefinityLabs.

the class ScenarioTest method test_returnsDynamicTest.

@Test
public void test_returnsDynamicTest() throws Throwable {
    Scenario scenario = Scenario.title("Title").given(stepOne).build();
    DynamicTest test = scenario.test(website);
    assertThat(test.getDisplayName()).isEqualTo(scenario.getTitle());
    test.getExecutable().execute();
    verify(stepOne).execute();
}
Also used : DynamicTest(org.junit.jupiter.api.DynamicTest) Test(org.junit.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 14 with DynamicTest

use of org.junit.jupiter.api.DynamicTest in project robozonky by RoboZonky.

the class JmxListenerServiceTest method getParametersForInvestmentMade.

private DynamicTest getParametersForInvestmentMade() {
    final Loan l = mockLoan();
    final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
    final PortfolioOverview po = PortfolioOverview.calculate(BigDecimal.valueOf(1000), Stream::empty);
    final Event evt = new InvestmentMadeEvent(i, l, po);
    final Consumer<SoftAssertions> before = (softly) -> {
        final OperationsMBean mbean = getOperationsMBean();
        softly.assertThat(mbean.getSuccessfulInvestments()).isEmpty();
    };
    final Consumer<SoftAssertions> after = (softly) -> {
        final OperationsMBean mbean = getOperationsMBean();
        softly.assertThat(mbean.getSuccessfulInvestments()).containsOnlyKeys(l.getId());
        softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
    };
    return getParameters(evt, before, after);
}
Also used : RecommendedLoan(com.github.robozonky.api.strategies.RecommendedLoan) ExecutionCompletedEvent(com.github.robozonky.api.notifications.ExecutionCompletedEvent) SoftAssertions(org.assertj.core.api.SoftAssertions) TestFactory(org.junit.jupiter.api.TestFactory) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) InvestmentDelegatedEvent(com.github.robozonky.api.notifications.InvestmentDelegatedEvent) SellingCompletedEvent(com.github.robozonky.api.notifications.SellingCompletedEvent) AfterAll(org.junit.jupiter.api.AfterAll) BigDecimal(java.math.BigDecimal) SellingStartedEvent(com.github.robozonky.api.notifications.SellingStartedEvent) SessionInfo(com.github.robozonky.api.notifications.SessionInfo) BeforeAll(org.junit.jupiter.api.BeforeAll) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) PurchasingStartedEvent(com.github.robozonky.api.notifications.PurchasingStartedEvent) Lifecycle(com.github.robozonky.app.runtime.Lifecycle) Assertions(org.assertj.core.api.Assertions) ShutdownHook(com.github.robozonky.app.ShutdownHook) InvestmentRejectedEvent(com.github.robozonky.api.notifications.InvestmentRejectedEvent) EventListenerSupplier(com.github.robozonky.api.notifications.EventListenerSupplier) LoanDescriptor(com.github.robozonky.api.strategies.LoanDescriptor) PurchasingCompletedEvent(com.github.robozonky.api.notifications.PurchasingCompletedEvent) InvestmentPurchasedEvent(com.github.robozonky.api.notifications.InvestmentPurchasedEvent) Event(com.github.robozonky.api.notifications.Event) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) Stream(java.util.stream.Stream) PortfolioOverview(com.github.robozonky.api.strategies.PortfolioOverview) EventListener(com.github.robozonky.api.notifications.EventListener) SaleOfferedEvent(com.github.robozonky.api.notifications.SaleOfferedEvent) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) DynamicTest(org.junit.jupiter.api.DynamicTest) Optional(java.util.Optional) ReturnCode(com.github.robozonky.api.ReturnCode) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent) RoboZonkyEndingEvent(com.github.robozonky.api.notifications.RoboZonkyEndingEvent) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest) Collections(java.util.Collections) RecommendedLoan(com.github.robozonky.api.strategies.RecommendedLoan) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) SoftAssertions(org.assertj.core.api.SoftAssertions) ExecutionCompletedEvent(com.github.robozonky.api.notifications.ExecutionCompletedEvent) InvestmentDelegatedEvent(com.github.robozonky.api.notifications.InvestmentDelegatedEvent) SellingCompletedEvent(com.github.robozonky.api.notifications.SellingCompletedEvent) SellingStartedEvent(com.github.robozonky.api.notifications.SellingStartedEvent) PurchasingStartedEvent(com.github.robozonky.api.notifications.PurchasingStartedEvent) InvestmentRejectedEvent(com.github.robozonky.api.notifications.InvestmentRejectedEvent) PurchasingCompletedEvent(com.github.robozonky.api.notifications.PurchasingCompletedEvent) InvestmentPurchasedEvent(com.github.robozonky.api.notifications.InvestmentPurchasedEvent) Event(com.github.robozonky.api.notifications.Event) SaleOfferedEvent(com.github.robozonky.api.notifications.SaleOfferedEvent) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent) RoboZonkyEndingEvent(com.github.robozonky.api.notifications.RoboZonkyEndingEvent) Stream(java.util.stream.Stream) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) PortfolioOverview(com.github.robozonky.api.strategies.PortfolioOverview) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent)

Example 15 with DynamicTest

use of org.junit.jupiter.api.DynamicTest in project robozonky by RoboZonky.

the class JmxListenerServiceTest method getParametersForInvestmentPurchased.

private DynamicTest getParametersForInvestmentPurchased() {
    final Loan l = mockLoan();
    final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
    final Event evt = new InvestmentPurchasedEvent(i, l, PortfolioOverview.calculate(BigDecimal.valueOf(2000), Stream::empty));
    final Consumer<SoftAssertions> before = (softly) -> {
        final OperationsMBean mbean = getOperationsMBean();
        softly.assertThat(mbean.getPurchasedInvestments()).isEmpty();
    };
    final Consumer<SoftAssertions> after = (softly) -> {
        final OperationsMBean mbean = getOperationsMBean();
        softly.assertThat(mbean.getPurchasedInvestments()).containsOnlyKeys(i.getLoanId());
        softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
    };
    return getParameters(evt, before, after);
}
Also used : RecommendedLoan(com.github.robozonky.api.strategies.RecommendedLoan) ExecutionCompletedEvent(com.github.robozonky.api.notifications.ExecutionCompletedEvent) SoftAssertions(org.assertj.core.api.SoftAssertions) TestFactory(org.junit.jupiter.api.TestFactory) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) InvestmentDelegatedEvent(com.github.robozonky.api.notifications.InvestmentDelegatedEvent) SellingCompletedEvent(com.github.robozonky.api.notifications.SellingCompletedEvent) AfterAll(org.junit.jupiter.api.AfterAll) BigDecimal(java.math.BigDecimal) SellingStartedEvent(com.github.robozonky.api.notifications.SellingStartedEvent) SessionInfo(com.github.robozonky.api.notifications.SessionInfo) BeforeAll(org.junit.jupiter.api.BeforeAll) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) PurchasingStartedEvent(com.github.robozonky.api.notifications.PurchasingStartedEvent) Lifecycle(com.github.robozonky.app.runtime.Lifecycle) Assertions(org.assertj.core.api.Assertions) ShutdownHook(com.github.robozonky.app.ShutdownHook) InvestmentRejectedEvent(com.github.robozonky.api.notifications.InvestmentRejectedEvent) EventListenerSupplier(com.github.robozonky.api.notifications.EventListenerSupplier) LoanDescriptor(com.github.robozonky.api.strategies.LoanDescriptor) PurchasingCompletedEvent(com.github.robozonky.api.notifications.PurchasingCompletedEvent) InvestmentPurchasedEvent(com.github.robozonky.api.notifications.InvestmentPurchasedEvent) Event(com.github.robozonky.api.notifications.Event) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) Stream(java.util.stream.Stream) PortfolioOverview(com.github.robozonky.api.strategies.PortfolioOverview) EventListener(com.github.robozonky.api.notifications.EventListener) SaleOfferedEvent(com.github.robozonky.api.notifications.SaleOfferedEvent) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) DynamicTest(org.junit.jupiter.api.DynamicTest) Optional(java.util.Optional) ReturnCode(com.github.robozonky.api.ReturnCode) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent) RoboZonkyEndingEvent(com.github.robozonky.api.notifications.RoboZonkyEndingEvent) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest) Collections(java.util.Collections) RecommendedLoan(com.github.robozonky.api.strategies.RecommendedLoan) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) SoftAssertions(org.assertj.core.api.SoftAssertions) ExecutionCompletedEvent(com.github.robozonky.api.notifications.ExecutionCompletedEvent) InvestmentDelegatedEvent(com.github.robozonky.api.notifications.InvestmentDelegatedEvent) SellingCompletedEvent(com.github.robozonky.api.notifications.SellingCompletedEvent) SellingStartedEvent(com.github.robozonky.api.notifications.SellingStartedEvent) PurchasingStartedEvent(com.github.robozonky.api.notifications.PurchasingStartedEvent) InvestmentRejectedEvent(com.github.robozonky.api.notifications.InvestmentRejectedEvent) PurchasingCompletedEvent(com.github.robozonky.api.notifications.PurchasingCompletedEvent) InvestmentPurchasedEvent(com.github.robozonky.api.notifications.InvestmentPurchasedEvent) Event(com.github.robozonky.api.notifications.Event) SaleOfferedEvent(com.github.robozonky.api.notifications.SaleOfferedEvent) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent) RoboZonkyEndingEvent(com.github.robozonky.api.notifications.RoboZonkyEndingEvent) InvestmentPurchasedEvent(com.github.robozonky.api.notifications.InvestmentPurchasedEvent) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment)

Aggregations

DynamicTest (org.junit.jupiter.api.DynamicTest)25 Test (org.junit.jupiter.api.Test)16 TestFactory (org.junit.jupiter.api.TestFactory)14 Stream (java.util.stream.Stream)10 RecommendedLoan (com.github.robozonky.api.strategies.RecommendedLoan)7 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)7 ReturnCode (com.github.robozonky.api.ReturnCode)6 Event (com.github.robozonky.api.notifications.Event)6 EventListener (com.github.robozonky.api.notifications.EventListener)6 EventListenerSupplier (com.github.robozonky.api.notifications.EventListenerSupplier)6 ExecutionCompletedEvent (com.github.robozonky.api.notifications.ExecutionCompletedEvent)6 InvestmentDelegatedEvent (com.github.robozonky.api.notifications.InvestmentDelegatedEvent)6 InvestmentMadeEvent (com.github.robozonky.api.notifications.InvestmentMadeEvent)6 InvestmentPurchasedEvent (com.github.robozonky.api.notifications.InvestmentPurchasedEvent)6 InvestmentRejectedEvent (com.github.robozonky.api.notifications.InvestmentRejectedEvent)6 PurchasingCompletedEvent (com.github.robozonky.api.notifications.PurchasingCompletedEvent)6 PurchasingStartedEvent (com.github.robozonky.api.notifications.PurchasingStartedEvent)6 RoboZonkyEndingEvent (com.github.robozonky.api.notifications.RoboZonkyEndingEvent)6 SaleOfferedEvent (com.github.robozonky.api.notifications.SaleOfferedEvent)6 SellingCompletedEvent (com.github.robozonky.api.notifications.SellingCompletedEvent)6