ImageRef { public String getImageName() { String[] splitted = image.split("/"); StringJoiner joiner = new StringJoiner("/"); Arrays.stream(splitted) .filter(token -> token.indexOf(".") < 0) .forEach(token -> joiner.add(token)); return joiner.toString(); } ImageRef(final String image); String getImage(); String getTag(); String getRegistryName(); String getRegistryUrl(); @Override String toString(); String getImageName();  }
@Test public void remoteImageWithUserName() { ImageRef ref = new ImageRef("docker.bank.swissquote.ch/djoaquim/image:3.3"); assertEquals("djoaquim/image", ref.getImageName()); }
@Test public void remoteImage() { ImageRef ref = new ImageRef("docker.bank.swissquote.ch/image:3.3"); assertEquals("image", ref.getImageName()); }
@Test public void localImageWithUserName() { ImageRef ref = new ImageRef("djoaquim/image:3.3"); assertEquals("djoaquim/image", ref.getImageName()); }
@Test public void localImage() { ImageRef ref = new ImageRef("image:3.3"); assertEquals("image", ref.getImageName()); }