DetectorClient { public void updatedDetectorLastUsed(UUID uuid) { val uri = String.format(baseUri + UPDATE_DETECTOR_LAST_USED_PATH); val bodyMap = Collections.singletonMap("detectorUuid", uuid); try { val body = objectMapper.writeValueAsString(bodyMap); httpClient.post(uri, body); } catch (IOException e) { val message = "IOException while updating detector's dateLastAccessed value for" + ": uuid=" + uuid + ", httpMethod=POST" + ", uri=" + uri; throw new DetectorException(message, e); } }  DetectorDocument findDetectorDocument(UUID uuid); List<DetectorDocument> findUpdatedDetectorDocuments(long timeInSecs); void updatedDetectorLastUsed(UUID uuid); DetectorMatchResponse findMatchingDetectorMappings(List<Map<String, String>> tagsList); List<DetectorMapping> findUpdatedDetectorMappings(long timeInSecs); DetectorMapping findDetectorMappingByUuid(UUID uuid);  }
@Test public void testUpdatedDetectorLastUsed() throws IOException { clientUnderTest.updatedDetectorLastUsed(DETECTOR_UUID); val bodyMap = buildDetectorMappingByUuidBody(DETECTOR_UUID); verify(objectMapper, times(1)).writeValueAsString(bodyMap); }
@Test(expected = DetectorException.class) public void testUpdatedDetectorLastUsed_detector_exception() throws IOException { val bodyMap_cantPost = buildDetectorMappingByUuidBody(DETECTOR_UUID); when(objectMapper.writeValueAsString(bodyMap_cantPost)).thenReturn(bodyMap_cantPost.toString()); when(httpClient.post(UPDATE_DETECTOR_LAST_USED_URI, bodyMap_cantPost.toString())).thenThrow(new IOException()); clientUnderTest.updatedDetectorLastUsed(DETECTOR_UUID); }