### Question:
OpenStackImageVerifier { public boolean exist(OSClient<?> osClient, String name) { return getStatus(osClient, name).isPresent(); }  boolean exist(OSClient<?> osClient, String name); Optional<ImageStatus> getStatus(OSClient<?> osClient, String name);  }### Answer:
@Test public void testNotFoundResult() { GlanceImage newImage1 = new GlanceImage(); newImage1.setId("id1"); newImage1.setName("exist-id1"); when(imageService.list(anyMap())).thenReturn(null); doReturn(ImmutableList.of(newImage1)).when(imageService).list(); assertFalse(underTest.exist(osClient, "invalidentryTgatResultsNull")); }
@Test(expected = CloudConnectorException.class) public void testFoundTwo() { try { GlanceImage newImage1 = new GlanceImage(); newImage1.setId("id1"); newImage1.setName("exist-id1"); GlanceImage newImage2 = new GlanceImage(); newImage2.setId("id2"); newImage2.setName("exist-id1"); List<GlanceImage> returnedImages = ImmutableList.of(newImage1, newImage2); Map<String, String> map = ImmutableMap.of("name", "exist-id1"); doReturn(returnedImages).when(imageService).list(ArgumentMatchers.eq(map)); underTest.exist(osClient, "exist-id1"); } catch (CloudConnectorException cce) { assertEquals("Multiple OpenStack images found with ids: id1, id2, image name: exist-id1", cce.getMessage()); throw cce; } }