@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); }
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(); }
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(); } }
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(); }  }
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(); }
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();  }