use of org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method shouldRetrieveImageHierarchyFromIntermediateImage.
@Test
public void shouldRetrieveImageHierarchyFromIntermediateImage() {
// given
final IDockerImage fooImage1 = this.connection.getImage("sha256:foo_image1");
// when
final IDockerImageHierarchyNode fooImage1Hierarchy = this.connection.resolveImageHierarchy(fooImage1);
// then
assertThat(fooImage1Hierarchy).isNotNull();
assertThat(fooImage1Hierarchy.getElement()).isEqualTo(fooImage1);
assertThat(getChildrenElementIds(fooImage1Hierarchy)).contains("sha256:foo_container1", "sha256:foo_image2");
final IDockerImage rootElement = (IDockerImage) fooImage1Hierarchy.getParent().getElement();
assertThat(rootElement.id()).isEqualTo("sha256:root_image");
// the parent only shows this child element, not its whole descendants
assertThat(fooImage1Hierarchy.getParent().getChildren()).containsExactly(fooImage1Hierarchy);
final IDockerImageHierarchyNode fooImage2HierarchyNode = fooImage1Hierarchy.getChild("sha256:foo_image2");
assertThat(fooImage2HierarchyNode).isNotNull();
// 2 child containers: foo_container21 and foo_container22
assertThat(fooImage2HierarchyNode.getChildren()).hasSize(2);
final IDockerImageHierarchyNode fooContainer1HierarchyNode = fooImage1Hierarchy.getChild("sha256:foo_container1");
assertThat(fooContainer1HierarchyNode).isNotNull();
assertThat(fooContainer1HierarchyNode.getChildren()).isEmpty();
}
use of org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method shouldRetrieveImageHierarchyFromRootImage.
@Test
public void shouldRetrieveImageHierarchyFromRootImage() {
// given
final IDockerImage rootImage = this.connection.getImage("sha256:root_image");
// when
final IDockerImageHierarchyNode rootImageHierarchy = this.connection.resolveImageHierarchy(rootImage);
// then
assertThat(rootImageHierarchy).isNotNull();
assertThat(rootImageHierarchy.getElement()).isEqualTo(rootImage);
// 2 direct children: foo_image1 and bar_image1
assertThat(rootImageHierarchy.getChildren()).hasSize(2);
assertThat(rootImageHierarchy.getParent()).isNull();
final IDockerImageHierarchyNode fooImage1Hierarchy = rootImageHierarchy.getChild("sha256:foo_image1");
assertThat(fooImage1Hierarchy.getParent()).isEqualTo(rootImageHierarchy);
// 2 direct children: foo_image2/foo_image2_alias and foo_container1
assertThat(fooImage1Hierarchy.getChildren()).hasSize(2);
}
use of org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method shouldRetrieveImageHierarchyFromContainerBasedOnLeafImage.
@Test
public void shouldRetrieveImageHierarchyFromContainerBasedOnLeafImage() {
// given
// when
final IDockerContainer barContainer1 = this.connection.getContainer("sha256:bar_container1");
final IDockerImageHierarchyNode barContainer1Hierarchy = this.connection.resolveImageHierarchy(barContainer1);
// then
assertThat(barContainer1Hierarchy).isNotNull();
assertThat(barContainer1Hierarchy.getElement()).isEqualTo(barContainer1);
assertThat(barContainer1Hierarchy.getChildren()).isEmpty();
final IDockerImage barImageElement = (IDockerImage) barContainer1Hierarchy.getParent().getElement();
assertThat(barImageElement.id()).isEqualTo("sha256:bar_image1");
}
use of org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method shouldRetrieveImageHierarchyFromContainerBasedOnIntermediateImage.
@Test
public void shouldRetrieveImageHierarchyFromContainerBasedOnIntermediateImage() {
// given
final IDockerContainer fooContainer1 = this.connection.getContainer("sha256:foo_container1");
// when
final IDockerImageHierarchyNode fooContainer1Hierarchy = this.connection.resolveImageHierarchy(fooContainer1);
// then
assertThat(fooContainer1Hierarchy).isNotNull();
assertThat(fooContainer1Hierarchy.getElement()).isEqualTo(fooContainer1);
assertThat(fooContainer1Hierarchy.getChildren()).isEmpty();
final IDockerImage fooImage1 = (IDockerImage) fooContainer1Hierarchy.getParent().getElement();
assertThat(fooImage1.id()).isEqualTo("sha256:foo_image1");
// parent images hierarchy only shows the selected container as its
// child.
assertThat(fooContainer1Hierarchy.getParent().getChildren()).containsExactly(fooContainer1Hierarchy);
}
use of org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode in project linuxtools by eclipse.
the class DockerImageHierarchyViewAssertions method hasSelectedElement.
public void hasSelectedElement(final Object expectedSelection) {
notNullValue();
final IStructuredSelection selection = (IStructuredSelection) actual.getCommonViewer().getSelection();
if (selection.size() != 1) {
failWithMessage("Expected Docker Image Hierarchy view to have <%s> selected elements, but there was <%s>", 1, selection.size());
}
final Object selectedElement = ((IDockerImageHierarchyNode) selection.getFirstElement()).getElement();
if (!selectedElement.equals(expectedSelection)) {
failWithMessage("Expected Docker Image Hierarchy view to have <%s> as the selected element, but it was <%s>", expectedSelection, selectedElement);
}
}
Aggregations