Search in sources :

Example 1 with Stop

use of com.oracle.bedrock.runtime.docker.commands.Stop in project oracle-bedrock by coherence-community.

the class DockerContainerTest method shouldStopContainer.

@Test
public void shouldStopContainer() throws Exception {
    Docker docker = Docker.auto();
    Platform platform = mock(Platform.class);
    Application application = mock(Application.class, "App");
    Application removeApp = mock(Application.class, "Inspect");
    DockerContainer container = new DockerContainer("foo", OptionsByType.of(docker));
    when(application.getPlatform()).thenReturn(platform);
    when(platform.launch(any(MetaClass.class), anyVararg())).thenReturn(removeApp);
    container.onAddingTo(application);
    container.stop();
    ArgumentCaptor<MetaClass> captor = ArgumentCaptor.forClass(MetaClass.class);
    verify(platform).launch(captor.capture(), anyVararg());
    OptionsByType optionsByType = OptionsByType.empty();
    Stop stop = (Stop) captor.getValue();
    assertThat(stop, is(notNullValue()));
    stop.onLaunch(platform, optionsByType);
    Arguments arguments = optionsByType.get(Arguments.class);
    List<String> values = arguments.resolve(mock(Platform.class), OptionsByType.empty());
    assertThat(values, contains("stop", "foo"));
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) MetaClass(com.oracle.bedrock.runtime.MetaClass) Stop(com.oracle.bedrock.runtime.docker.commands.Stop) Arguments(com.oracle.bedrock.runtime.options.Arguments) Matchers.anyString(org.mockito.Matchers.anyString) Application(com.oracle.bedrock.runtime.Application) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Aggregations

OptionsByType (com.oracle.bedrock.OptionsByType)1 Application (com.oracle.bedrock.runtime.Application)1 MetaClass (com.oracle.bedrock.runtime.MetaClass)1 Platform (com.oracle.bedrock.runtime.Platform)1 Stop (com.oracle.bedrock.runtime.docker.commands.Stop)1 Arguments (com.oracle.bedrock.runtime.options.Arguments)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1