This is an automated email from the ASF dual-hosted git repository. dpavlov pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
The following commit(s) were added to refs/heads/master by this push: new 9e7757f IGNITE-9901 Tests fixed after recent merges 9e7757f is described below commit 9e7757f824ab7518ca6a9497de0bc9adbb882022 Author: Dmitriy Pavlov <dpav...@apache.org> AuthorDate: Wed Oct 24 16:56:59 2018 +0300 IGNITE-9901 Tests fixed after recent merges --- .../org/apache/ignite/ci/di/DiContextTest.java | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/di/DiContextTest.java b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/di/DiContextTest.java index 9b01eec..690914b 100644 --- a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/di/DiContextTest.java +++ b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/di/DiContextTest.java @@ -19,17 +19,19 @@ package org.apache.ignite.ci.di; import com.google.common.base.Preconditions; import com.google.inject.Guice; import com.google.inject.Injector; +import java.util.Collection; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.Ignite; import org.apache.ignite.ci.ITcHelper; -import org.apache.ignite.ci.teamcity.pure.ITcServerProvider; import org.apache.ignite.ci.observer.BuildObserver; import org.apache.ignite.ci.observer.ObserverTask; +import org.apache.ignite.ci.teamcity.pure.ITcServerProvider; import org.apache.ignite.ci.teamcity.restcached.ITcServerFactory; import org.apache.ignite.ci.web.TcUpdatePool; import org.junit.Test; -import java.util.Collection; - import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; public class DiContextTest { /** @@ -37,21 +39,26 @@ public class DiContextTest { */ @Test public void checkSingletons() { - IgniteTcBotModule igniteTcBotModule = new IgniteTcBotModule(); - Injector injector = Guice.createInjector(igniteTcBotModule); + Injector injector = getInjector(); validateInstanceCachedFor(injector, ITcServerProvider.class); validateInstanceCachedFor(injector, ITcServerFactory.class); validateInstanceCachedFor(injector, ObserverTask.class); } + public Injector getInjector() { + IgniteTcBotModule igniteTcBotModule = new IgniteTcBotModule(); + igniteTcBotModule.setIgniteFut(CompletableFuture.completedFuture(mock(Ignite.class))); + + return Guice.createInjector(igniteTcBotModule); + } + /** * */ @Test public void checkPoolIsOne() { - IgniteTcBotModule igniteTcBotModule = new IgniteTcBotModule(); - Injector injector = Guice.createInjector(igniteTcBotModule); + Injector injector = getInjector(); TcUpdatePool pool = injector.getInstance(TcUpdatePool.class); Preconditions.checkState(pool == injector.getInstance((Class<?>) TcUpdatePool.class), @@ -73,22 +80,21 @@ public class DiContextTest { IgniteTcBotModule igniteTcBotModule = new IgniteTcBotModule(); final Injector injector = Guice.createInjector(igniteTcBotModule); final MonitorTest instance = injector.getInstance(MonitorTest.class); - final String parameter = "parameter"; - instance.doSmth(parameter); + + final String param = "parameter"; + instance.doSmth(param); instance.doSmth(); final MonitoredTaskInterceptor interceptor = injector.getInstance(MonitoredTaskInterceptor.class); final Collection<MonitoredTaskInterceptor.Invocation> list = interceptor.getList(); boolean foundPar = false, found = false; for (MonitoredTaskInterceptor.Invocation next : list) { - final String fullParametrized = MonitorTest.TASK_NME + "." + parameter; - if (fullParametrized.equals(next.name())) { + final String fullParametrized = MonitorTest.TASK_NME + "." + param; + if (fullParametrized.equals(next.name())) foundPar = true; - } - if (MonitorTest.TASK_NME .equals(next.name())) { + if (MonitorTest.TASK_NME .equals(next.name())) found = true; - } } assertTrue(foundPar); @@ -109,8 +115,7 @@ public class DiContextTest { @Test public void checkSingletonTcHelper() { - IgniteTcBotModule igniteTcBotModule = new IgniteTcBotModule(); - Injector injector = Guice.createInjector(igniteTcBotModule); + Injector injector = getInjector(); validateInstanceCachedFor(injector, ITcHelper.class);