use of org.eclipse.linuxtools.docker.core.IDockerImageInfo in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModelTest method checkThatRemoveAnExistingServicePortIsEffective.
@Test
public void checkThatRemoveAnExistingServicePortIsEffective() {
// assume Docker image is on local
final IDockerImageInfo dockerImageInfo = Mockito.mock(IDockerImageInfo.class, Mockito.RETURNS_DEEP_STUBS);
when(dockerConnection.hasImage(WILDFLY_IMAGE, LATEST_TAG)).thenReturn(true);
when(dockerConnection.getImageInfo(WILDFLY_IMAGE_URI)).thenReturn(dockerImageInfo);
when(dockerImageInfo.config().env()).thenReturn(Collections.emptyList());
when(dockerImageInfo.config().exposedPorts()).thenReturn(new HashSet<>(Arrays.asList("8080/tcp", "9990/tcp")));
when(dockerImageInfo.config().volumes()).thenReturn(Collections.emptySet());
when(dockerImageInfo.containerConfig()).thenReturn(null);
mockSingleImage(dockerConnection, WILDFLY_IMAGE, LATEST_TAG);
// when
model.setImageName(WILDFLY_IMAGE_URI);
final boolean result = model.initializeContainerInfo();
// then
assertThat(result).isTrue();
model.removeServicePort(model.getServicePorts().get(0));
assertThat(model.getServicePorts()).hasSize(1);
assertThat(model.getServicePorts()).isEqualTo(Collections.singletonList(new ServicePortAdapter(new PortSpecAdapter("9990-tcp", "TCP", 9990))));
}
use of org.eclipse.linuxtools.docker.core.IDockerImageInfo in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModelTest method checkThatRemoveAnExistingEnvironmentVariableIsEffective.
@Test
public void checkThatRemoveAnExistingEnvironmentVariableIsEffective() {
// assume Docker image is on local
final IDockerImageInfo dockerImageInfo = Mockito.mock(IDockerImageInfo.class, Mockito.RETURNS_DEEP_STUBS);
when(dockerConnection.hasImage(WILDFLY_IMAGE, LATEST_TAG)).thenReturn(true);
when(dockerConnection.getImageInfo(WILDFLY_IMAGE_URI)).thenReturn(dockerImageInfo);
mockSingleImage(dockerConnection, WILDFLY_IMAGE, LATEST_TAG);
when(dockerImageInfo.config().env()).thenReturn(Arrays.asList("V1=value1", "V2=value2"));
when(dockerImageInfo.config().exposedPorts()).thenReturn(Collections.emptySet());
when(dockerImageInfo.config().volumes()).thenReturn(Collections.emptySet());
when(dockerImageInfo.containerConfig()).thenReturn(null);
// when
model.setImageName(WILDFLY_IMAGE_URI);
final boolean result = model.initializeContainerInfo();
// then
assertThat(result).isTrue();
model.removeEnvironmentVariable(model.getEnvironmentVariable("V1"));
assertThat(model.getEnvironmentVariables()).hasSize(2);
// Deleted existing environment variable is marked as deleted, but remains in the table.
assertThat(model.isEnvironmentVariableDeleted(model.getEnvironmentVariable("V1"))).isTrue();
assertThat(model.getEnvironmentVariable("V2").getValue()).isEqualTo("value2");
}
Aggregations