### Question:
NessusAdapterV1 extends AbstractAdapter<NessusAdapterContext, NessusAdapterConfig> implements NessusAdapter { String resolveHistoryIdByUUID(String content, NessusAdapterContext context) throws AdapterException { String uuid = context.getProductContextId(); if (uuid == null) { throw new IllegalStateException("No nessus uuid available!"); } return context.json().fetch("history", content) .fetchArrayElementHaving("history_id", Collections.singletonMap("uuid", uuid)).asText(); }  @Override String execute(NessusAdapterConfig config,AdapterRuntimeContext runtimeContext); @Override int getAdapterVersion();  }### Answer:
@Test public void resolveHistoryIdByUUID_no_uuid_set_illegal_state_is_thrown() throws Exception { expected.expect(IllegalStateException.class); when(context.getProductContextId()).thenReturn(null); adapterToTest.resolveHistoryIdByUUID("{}", context); }
@Test public void resolveHistoryIdByUUID_empty_obj_throws_adapterexception() throws Exception { expected.expect(AdapterException.class); when(context.getProductContextId()).thenReturn("uuid"); adapterToTest.resolveHistoryIdByUUID("{}", context); }
@Test public void resolveHistoryIdByUUID_non_existing_uuid_throws_adapter_exception() throws Exception { expected.expect(AdapterException.class); String content = "{\"history\":[{\"uuid\":\"my-uuid\", \"history_id\":\"666\"}]}"; when(context.getProductContextId()).thenReturn("unkown-uuid"); adapterToTest.resolveHistoryIdByUUID(content, context); }
@Test public void resolveHistoryIdByUUID__existing_uuid_myUUID_returns_history_id_666() throws Exception { String content = "{\"history\":[{\"uuid\":\"my-uuid\", \"history_id\":\"666\"}]}"; when(context.getProductContextId()).thenReturn("my-uuid"); String result = adapterToTest.resolveHistoryIdByUUID(content,context); assertEquals("666", result); }