Search in sources :

Example 1 with BeforeEach

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

the class AppTest method cleanup.

@BeforeEach
@AfterEach
public void cleanup() {
    File file = new File("testfile.txt");
    file.delete();
}
Also used : File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach) AfterEach(org.junit.jupiter.api.AfterEach)

Example 2 with BeforeEach

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

the class MongoTicketRepositoryTest method init.

@BeforeEach
public void init() {
    MongoConnectionPropertiesLoader.load();
    MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
    mongoClient.dropDatabase(TEST_DB);
    mongoClient.close();
    repository = new MongoTicketRepository(TEST_DB, TEST_TICKETS_COLLECTION, TEST_COUNTERS_COLLECTION);
}
Also used : MongoClient(com.mongodb.MongoClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with BeforeEach

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

the class MongoEventLogTest method init.

@BeforeEach
public void init() {
    MongoConnectionPropertiesLoader.load();
    MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
    mongoClient.dropDatabase(TEST_DB);
    mongoClient.close();
    mongoEventLog = new MongoEventLog(TEST_DB, TEST_EVENTS_COLLECTION);
}
Also used : MongoClient(com.mongodb.MongoClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with BeforeEach

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

the class FileListManagerTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    files = new TestFileManager(getClass());
    Path settingsFile = files.addFile(SETTINGS_JSON);
    target = new FileListManagerImpl(settingsFile);
    Path path1 = files.addFile("file1");
    file1 = new SessionListedFile(path1, true);
    Path path2 = files.addFile("file2");
    file2 = new DocumentListedFile(path2);
    Path path3 = files.addFile("file3");
    file3 = new ExcelListedFile(path3, Arrays.asList(1, 2, 3));
}
Also used : Path(java.nio.file.Path) TestFileManager(io.github.vocabhunter.test.utils.TestFileManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with BeforeEach

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

the class GuiTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    when(environmentManager.useSystemMenuBar()).thenReturn(false);
    when(environmentManager.isExitOptionShown()).thenReturn(true);
    when(placementManager.getMainWindow()).thenReturn(new Placement(WINDOW_WIDTH, WINDOW_HEIGHT));
    manager = new TestFileManager(getClass());
    Path settingsFile = manager.addFile(SettingsManagerImpl.SETTINGS_JSON);
    SettingsManager settingsManager = new SettingsManagerImpl(settingsFile);
    Path fileListManagerFile = manager.addFile(FileListManagerImpl.SETTINGS_JSON);
    FileListManager fileListManager = new FileListManagerImpl(fileListManagerFile);
    CoreGuiModule coreModule = new CoreGuiModule();
    Module testModule = new AbstractModule() {

        @Override
        protected void configure() {
            bind(SettingsManager.class).toInstance(settingsManager);
            bind(FileListManager.class).toInstance(fileListManager);
            bind(FileDialogueFactory.class).toInstance(fileDialogueFactory);
            bind(EnvironmentManager.class).toInstance(environmentManager);
            bind(PlacementManager.class).toInstance(placementManager);
            bind(WebPageTool.class).toInstance(webPageTool);
            bind(GuiTaskHandler.class).to(GuiTaskHandlerForTesting.class);
        }
    };
    VocabHunterGuiExecutable.setModules(coreModule, testModule, new StandardEventSourceModule());
    setupApplication(VocabHunterGuiExecutable.class);
}
Also used : Path(java.nio.file.Path) WebPageTool(io.github.vocabhunter.gui.services.WebPageTool) SettingsManagerImpl(io.github.vocabhunter.gui.settings.SettingsManagerImpl) EnvironmentManager(io.github.vocabhunter.gui.services.EnvironmentManager) SettingsManager(io.github.vocabhunter.gui.settings.SettingsManager) TestFileManager(io.github.vocabhunter.test.utils.TestFileManager) FileListManagerImpl(io.github.vocabhunter.analysis.settings.FileListManagerImpl) FileDialogueFactory(io.github.vocabhunter.gui.dialogues.FileDialogueFactory) AbstractModule(com.google.inject.AbstractModule) FileListManager(io.github.vocabhunter.analysis.settings.FileListManager) PlacementManager(io.github.vocabhunter.gui.services.PlacementManager) Placement(io.github.vocabhunter.gui.common.Placement) GuiTaskHandler(io.github.vocabhunter.analysis.core.GuiTaskHandler) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BeforeEach (org.junit.jupiter.api.BeforeEach)13 TestFileManager (io.github.vocabhunter.test.utils.TestFileManager)6 MongoClient (com.mongodb.MongoClient)3 Path (java.nio.file.Path)3 File (java.io.File)2 AfterEach (org.junit.jupiter.api.AfterEach)2 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 GuiTaskHandler (io.github.vocabhunter.analysis.core.GuiTaskHandler)1 FileListManager (io.github.vocabhunter.analysis.settings.FileListManager)1 FileListManagerImpl (io.github.vocabhunter.analysis.settings.FileListManagerImpl)1 Placement (io.github.vocabhunter.gui.common.Placement)1 FileDialogueFactory (io.github.vocabhunter.gui.dialogues.FileDialogueFactory)1 EnvironmentManager (io.github.vocabhunter.gui.services.EnvironmentManager)1 PlacementManager (io.github.vocabhunter.gui.services.PlacementManager)1 WebPageTool (io.github.vocabhunter.gui.services.WebPageTool)1 SettingsManager (io.github.vocabhunter.gui.settings.SettingsManager)1 SettingsManagerImpl (io.github.vocabhunter.gui.settings.SettingsManagerImpl)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1