use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerImage method onClosed.
@Override
public void onClosed(Application application, OptionsByType optionsByType) {
OptionsByType closingOptions;
if (application != null) {
closingOptions = OptionsByType.of(application.getOptions());
closingOptions.addAll(optionsByType);
} else {
closingOptions = optionsByType;
}
ImageCloseBehaviour behaviour = closingOptions.get(ImageCloseBehaviour.class);
behaviour.accept(this);
}
use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerImageTest method shouldCloseWithNullApplication.
@Test
public void shouldCloseWithNullApplication() throws Exception {
DockerImage image = new DockerImage(Arrays.asList("foo", "bar"), OptionsByType.empty());
ImageCloseBehaviour behaviour = mock(ImageCloseBehaviour.class);
image.onClosed(null, OptionsByType.of(behaviour));
verify(behaviour).accept(same(image));
}
use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerImageTest method shouldCloseWithApplicationAndUseApplicationCloseBehaviour.
@Test
public void shouldCloseWithApplicationAndUseApplicationCloseBehaviour() throws Exception {
Application application = mock(Application.class);
DockerImage image = new DockerImage(Arrays.asList("foo", "bar"), OptionsByType.empty());
ImageCloseBehaviour behaviourApp = mock(ImageCloseBehaviour.class);
when(application.getOptions()).thenReturn(OptionsByType.of(behaviourApp));
image.onClosed(application, OptionsByType.empty());
verify(behaviourApp).accept(same(image));
}
use of com.oracle.bedrock.runtime.docker.options.ImageCloseBehaviour in project oracle-bedrock by coherence-community.
the class DockerImageTest method shouldCloseWithApplicationAndUseOverridingBehaviour.
@Test
public void shouldCloseWithApplicationAndUseOverridingBehaviour() throws Exception {
Application application = mock(Application.class);
DockerImage image = new DockerImage(Arrays.asList("foo", "bar"), OptionsByType.empty());
ImageCloseBehaviour behaviourApp = mock(ImageCloseBehaviour.class, "1");
ImageCloseBehaviour behaviourOverride = mock(ImageCloseBehaviour.class, "2");
when(application.getOptions()).thenReturn(OptionsByType.of(behaviourApp));
image.onClosed(application, OptionsByType.of(behaviourOverride));
verify(behaviourApp, never()).accept(same(image));
verify(behaviourOverride).accept(same(image));
}
Aggregations