Search in sources :

Example 1 with BeforeAll

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

the class IntegrationTest method initializeAndPopulateDatabase.

@BeforeAll
public static void initializeAndPopulateDatabase() {
    commandService = new CommandServiceImpl();
    queryService = new QueryServiceImpl();
    // create first author1
    commandService.authorCreated("username1", "name1", "email1");
    // create author1 and update all its data
    commandService.authorCreated("username2", "name2", "email2");
    commandService.authorEmailUpdated("username2", "new_email2");
    commandService.authorNameUpdated("username2", "new_name2");
    commandService.authorUsernameUpdated("username2", "new_username2");
    // add book1 to author1
    commandService.bookAddedToAuthor("title1", 10, "username1");
    // add book2 to author1 and update all its data
    commandService.bookAddedToAuthor("title2", 20, "username1");
    commandService.bookPriceUpdated("title2", 30);
    commandService.bookTitleUpdated("title2", "new_title2");
}
Also used : CommandServiceImpl(com.iluwatar.cqrs.commandes.CommandServiceImpl) QueryServiceImpl(com.iluwatar.cqrs.queries.QueryServiceImpl) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with BeforeAll

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

the class DateFormatCallableTest method setup.

/**
 * Run Callable and prepare results for usage in the test methods
 */
@BeforeAll
public static void setup() {
    // Create a callable
    DateFormatCallable callableDf = new DateFormatCallable("dd/MM/yyyy", "15/12/2015");
    // start thread using the Callable instance
    ExecutorService executor = Executors.newCachedThreadPool();
    Future<Result> futureResult = executor.submit(callableDf);
    try {
        result = futureResult.get();
        createdDateValues = convertDatesToString(result);
    } catch (Exception e) {
        fail("Setup failed: " + e);
    }
    executor.shutdown();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with BeforeAll

use of org.junit.jupiter.api.BeforeAll in project VocabHunter by VocabHunter.

the class AnalysisSystemTest method setUpClass.

@BeforeAll
public static void setUpClass() throws Exception {
    Analyser analyser = new SimpleAnalyser();
    FileStreamer target = new FileStreamer(analyser);
    URL resource = FileStreamerTest.class.getResource("/" + INPUT_DOCUMENT);
    Path file = Paths.get(resource.toURI());
    EnrichedSessionState enrichedSession = target.createNewSession(file);
    SessionState sessionState = enrichedSession.getState();
    words = sessionState.getOrderedUses();
}
Also used : Path(java.nio.file.Path) SessionState(io.github.vocabhunter.analysis.session.SessionState) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState) SimpleAnalyser(io.github.vocabhunter.analysis.simple.SimpleAnalyser) Analyser(io.github.vocabhunter.analysis.model.Analyser) SimpleAnalyser(io.github.vocabhunter.analysis.simple.SimpleAnalyser) URL(java.net.URL) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with BeforeAll

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

the class DateFormatCallableTestIncorrectDateFormat method setup.

/**
 * Run Callable and prepare results for usage in the test methods
 */
@BeforeAll
public static void setup() {
    // Create a callable. Pass a string date value not matching the format string
    DateFormatCallable callableDf = new DateFormatCallable("dd/MM/yyyy", "15.12.2015");
    // start thread using the Callable instance
    ExecutorService executor = Executors.newCachedThreadPool();
    Future<Result> futureResult = executor.submit(callableDf);
    try {
        result = futureResult.get();
    } catch (Exception e) {
        fail("Setup failed: " + e);
    }
    executor.shutdown();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with BeforeAll

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

the class DateFormatCallableTestMultiThread method setup.

/**
 * Run Callable and prepare results for usage in the test methods
 */
@BeforeAll
public static void setup() {
    // Create a callable
    DateFormatCallable callableDf = new DateFormatCallable("dd/MM/yyyy", "15/12/2015");
    // start thread using the Callable instance
    ExecutorService executor = Executors.newCachedThreadPool();
    Future<Result> futureResult1 = executor.submit(callableDf);
    Future<Result> futureResult2 = executor.submit(callableDf);
    Future<Result> futureResult3 = executor.submit(callableDf);
    Future<Result> futureResult4 = executor.submit(callableDf);
    try {
        result[0] = futureResult1.get();
        result[1] = futureResult2.get();
        result[2] = futureResult3.get();
        result[3] = futureResult4.get();
        for (int i = 0; i < result.length; i++) {
            createdDateValues[i] = convertDatesToString(result[i]);
        }
    } catch (Exception e) {
        fail("Setup failed: " + e);
    }
    executor.shutdown();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

BeforeAll (org.junit.jupiter.api.BeforeAll)8 ExecutorService (java.util.concurrent.ExecutorService)3 Account (io.nem.sdk.model.account.Account)2 DefaultNemClientFactory (com.github.rosklyar.client.DefaultNemClientFactory)1 CommandServiceImpl (com.iluwatar.cqrs.commandes.CommandServiceImpl)1 QueryServiceImpl (com.iluwatar.cqrs.queries.QueryServiceImpl)1 Analyser (io.github.vocabhunter.analysis.model.Analyser)1 EnrichedSessionState (io.github.vocabhunter.analysis.session.EnrichedSessionState)1 SessionState (io.github.vocabhunter.analysis.session.SessionState)1 SimpleAnalyser (io.github.vocabhunter.analysis.simple.SimpleAnalyser)1 PublicAccount (io.nem.sdk.model.account.PublicAccount)1 URL (java.net.URL)1 Path (java.nio.file.Path)1