Search in sources :

Example 16 with Test

use of org.junit.jupiter.api.Test in project java-design-patterns by iluwatar.

the class MenuViewTest method testStoreChanged.

@Test
public void testStoreChanged() throws Exception {
    final MenuStore store = mock(MenuStore.class);
    when(store.getSelected()).thenReturn(MenuItem.HOME);
    final MenuView view = new MenuView();
    view.storeChanged(store);
    verify(store, times(1)).getSelected();
    verifyNoMoreInteractions(store);
}
Also used : MenuStore(com.iluwatar.flux.store.MenuStore) Test(org.junit.jupiter.api.Test)

Example 17 with Test

use of org.junit.jupiter.api.Test in project java-design-patterns by iluwatar.

the class MenuViewTest method testItemClicked.

@Test
public void testItemClicked() throws Exception {
    final Store store = mock(Store.class);
    Dispatcher.getInstance().registerStore(store);
    final MenuView view = new MenuView();
    view.itemClicked(MenuItem.PRODUCTS);
    // We should receive a menu click action and a content changed action
    verify(store, times(2)).onAction(any(Action.class));
}
Also used : Action(com.iluwatar.flux.action.Action) MenuStore(com.iluwatar.flux.store.MenuStore) Store(com.iluwatar.flux.store.Store) Test(org.junit.jupiter.api.Test)

Example 18 with Test

use of org.junit.jupiter.api.Test in project java-design-patterns by iluwatar.

the class AsynchronousServiceTest method testPerfectExecution.

@Test
public void testPerfectExecution() throws Exception {
    final AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
    final AsyncTask<Object> task = mock(AsyncTask.class);
    final Object result = new Object();
    when(task.call()).thenReturn(result);
    service.execute(task);
    verify(task, timeout(2000)).onPostCall(eq(result));
    final InOrder inOrder = inOrder(task);
    inOrder.verify(task, times(1)).onPreCall();
    inOrder.verify(task, times(1)).call();
    inOrder.verify(task, times(1)).onPostCall(eq(result));
    verifyNoMoreInteractions(task);
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.jupiter.api.Test)

Example 19 with Test

use of org.junit.jupiter.api.Test in project java-design-patterns by iluwatar.

the class MongoEventLogTest method testFundTransfers.

@Test
public void testFundTransfers() {
    PlayerDetails playerDetails = new PlayerDetails("john@wayne.com", "000-000", "03432534543");
    mongoEventLog.prizeError(playerDetails, 1000);
    assertEquals(1, mongoEventLog.getEventsCollection().count());
    mongoEventLog.prizeError(playerDetails, 1000);
    assertEquals(2, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketDidNotWin(playerDetails);
    assertEquals(3, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketDidNotWin(playerDetails);
    assertEquals(4, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketSubmitError(playerDetails);
    assertEquals(5, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketSubmitError(playerDetails);
    assertEquals(6, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketSubmitted(playerDetails);
    assertEquals(7, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketSubmitted(playerDetails);
    assertEquals(8, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketWon(playerDetails, 1000);
    assertEquals(9, mongoEventLog.getEventsCollection().count());
    mongoEventLog.ticketWon(playerDetails, 1000);
    assertEquals(10, mongoEventLog.getEventsCollection().count());
}
Also used : PlayerDetails(com.iluwatar.hexagonal.domain.PlayerDetails) Test(org.junit.jupiter.api.Test)

Example 20 with Test

use of org.junit.jupiter.api.Test in project java-design-patterns by iluwatar.

the class MuteTest method loggedMuteShouldLogExceptionTraceBeforeSwallowingIt.

@Test
public void loggedMuteShouldLogExceptionTraceBeforeSwallowingIt() throws IOException {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    System.setErr(new PrintStream(stream));
    Mute.loggedMute(() -> methodThrowingException());
    assertTrue(new String(stream.toByteArray()).contains(MESSAGE));
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)265 BigInteger (java.math.BigInteger)50 JsonObject (io.vertx.core.json.JsonObject)20 NemAnnounceResult (com.github.rosklyar.client.transaction.domain.NemAnnounceResult)15 PublicAccount (io.nem.sdk.model.account.PublicAccount)14 AnalysisResult (io.github.vocabhunter.analysis.model.AnalysisResult)12 Address (io.nem.sdk.model.account.Address)10 NamespaceId (io.nem.sdk.model.namespace.NamespaceId)10 ExecutorService (java.util.concurrent.ExecutorService)9 UnconfirmedTransactions (com.github.rosklyar.client.account.domain.transaction.UnconfirmedTransactions)7 MosaicId (com.github.rosklyar.client.transaction.domain.mosaic.MosaicId)7 Transactions (com.github.rosklyar.client.account.domain.transaction.Transactions)6 PsiClass (com.intellij.psi.PsiClass)6 Mosaic (io.nem.sdk.model.mosaic.Mosaic)6 MosaicId (io.nem.sdk.model.mosaic.MosaicId)6 Disabled (org.junit.jupiter.api.Disabled)6 DisplayName (org.junit.jupiter.api.DisplayName)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 InOrder (org.mockito.InOrder)6 SpellDao (com.iluwatar.servicelayer.spell.SpellDao)5