Skip to content

Commit

Permalink
Service/Module override support #6
Browse files Browse the repository at this point in the history
proper itests
  • Loading branch information
andrus committed Dec 21, 2015
1 parent 26bdfa9 commit 1dd7483
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 50 deletions.
40 changes: 3 additions & 37 deletions src/test/java/com/nhl/bootique/BootiqueIT.java
Expand Up @@ -2,55 +2,21 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.google.inject.Module;
import com.nhl.bootique.it.ItestModule;
import com.nhl.bootique.it.ItestModuleProvider;

public class BootiqueIT {

@Before
public void before() {
ItestModule.MOCK_DELEGATE = mock(Module.class);
}

@After
public void after() {
ItestModuleProvider.REPLACES = null;
ItestModule.MOCK_DELEGATE = null;
}

@Test
public void testCreateAutoLoadModules() {
Collection<Module> autoLoaded = Bootique.app(new String[0]).autoLoadModules()
.createAutoLoadModules(Collections.emptyList());
public void testAutoLoadedProviders() {
Collection<BQModuleProvider> autoLoaded = Bootique.app(new String[0]).autoLoadedProviders();

assertEquals(1, autoLoaded.size());
autoLoaded.forEach(m -> assertTrue(m instanceof ItestModule));
}

@Test
public void testCreateAutoLoadModules_ExplicitIgnored() {

Collection<Module> existing = Arrays.asList(new ItestModule());
assertEquals(0, Bootique.app(new String[0]).autoLoadModules().createAutoLoadModules(existing).size());
autoLoaded.forEach(m -> assertTrue(m instanceof ItestModuleProvider));
}

@Test
public void testCreateAutoLoadModules_ReplaceAnotherModule() {

ItestModuleProvider.REPLACES = BQCoreModule.class;

Collection<Module> existing = Arrays.asList(new ItestModule());
assertEquals(0, Bootique.app(new String[0]).autoLoadModules().createAutoLoadModules(existing).size());
}
}
6 changes: 1 addition & 5 deletions src/test/java/com/nhl/bootique/it/ItestModule.java
Expand Up @@ -5,13 +5,9 @@

public class ItestModule implements Module {

public static Module MOCK_DELEGATE;

@Override
public void configure(Binder binder) {
if (MOCK_DELEGATE != null) {
MOCK_DELEGATE.configure(binder);
}
// do nothing for now
}

}
8 changes: 0 additions & 8 deletions src/test/java/com/nhl/bootique/it/ItestModuleProvider.java
@@ -1,21 +1,13 @@
package com.nhl.bootique.it;

import java.util.Optional;

import com.google.inject.Module;
import com.nhl.bootique.BQModuleProvider;

public class ItestModuleProvider implements BQModuleProvider {

public static Class<? extends Module> REPLACES;

@Override
public Module module() {
return new ItestModule();
}

@Override
public Optional<Class<? extends Module>> replaces() {
return Optional.ofNullable(REPLACES);
}
}

0 comments on commit 1dd7483

Please sign in to comment.