@Test public void resolvePolicyUIDByTitle_empty_obj_throws_adapterexception() throws Exception { expected.expect(AdapterException.class); adapterToTest.resolvePolicyUIDByTitle("{}", "x",context); }
String resolvePolicyUIDByTitle(String content, String searchedPolicyTitle, NessusAdapterContext context) throws AdapterException { try { ArrayNode templatesArray = context.json().fetch("templates", content).asArray(); for (Iterator<JsonNode> elements = templatesArray.elements(); elements.hasNext();) { JsonNode node = elements.next(); String title = context.json().fetch("title", node).asText(); if (searchedPolicyTitle.equals(title)) { return context.json().fetch("uuid", node).asText(); } } return null; } catch (Exception e) { throw asAdapterException("Was not able to resolve policy uid", e, context); } }
NessusAdapterV1 extends AbstractAdapter<NessusAdapterContext, NessusAdapterConfig> implements NessusAdapter { String resolvePolicyUIDByTitle(String content, String searchedPolicyTitle, NessusAdapterContext context) throws AdapterException { try { ArrayNode templatesArray = context.json().fetch("templates", content).asArray(); for (Iterator<JsonNode> elements = templatesArray.elements(); elements.hasNext();) { JsonNode node = elements.next(); String title = context.json().fetch("title", node).asText(); if (searchedPolicyTitle.equals(title)) { return context.json().fetch("uuid", node).asText(); } } return null; } catch (Exception e) { throw asAdapterException("Was not able to resolve policy uid", e, context); } } }
NessusAdapterV1 extends AbstractAdapter<NessusAdapterContext, NessusAdapterConfig> implements NessusAdapter { String resolvePolicyUIDByTitle(String content, String searchedPolicyTitle, NessusAdapterContext context) throws AdapterException { try { ArrayNode templatesArray = context.json().fetch("templates", content).asArray(); for (Iterator<JsonNode> elements = templatesArray.elements(); elements.hasNext();) { JsonNode node = elements.next(); String title = context.json().fetch("title", node).asText(); if (searchedPolicyTitle.equals(title)) { return context.json().fetch("uuid", node).asText(); } } return null; } catch (Exception e) { throw asAdapterException("Was not able to resolve policy uid", e, context); } }  }
NessusAdapterV1 extends AbstractAdapter<NessusAdapterContext, NessusAdapterConfig> implements NessusAdapter { String resolvePolicyUIDByTitle(String content, String searchedPolicyTitle, NessusAdapterContext context) throws AdapterException { try { ArrayNode templatesArray = context.json().fetch("templates", content).asArray(); for (Iterator<JsonNode> elements = templatesArray.elements(); elements.hasNext();) { JsonNode node = elements.next(); String title = context.json().fetch("title", node).asText(); if (searchedPolicyTitle.equals(title)) { return context.json().fetch("uuid", node).asText(); } } return null; } catch (Exception e) { throw asAdapterException("Was not able to resolve policy uid", e, context); } }  @Override String execute(NessusAdapterConfig config,AdapterRuntimeContext runtimeContext); @Override int getAdapterVersion(); }
NessusAdapterV1 extends AbstractAdapter<NessusAdapterContext, NessusAdapterConfig> implements NessusAdapter { String resolvePolicyUIDByTitle(String content, String searchedPolicyTitle, NessusAdapterContext context) throws AdapterException { try { ArrayNode templatesArray = context.json().fetch("templates", content).asArray(); for (Iterator<JsonNode> elements = templatesArray.elements(); elements.hasNext();) { JsonNode node = elements.next(); String title = context.json().fetch("title", node).asText(); if (searchedPolicyTitle.equals(title)) { return context.json().fetch("uuid", node).asText(); } } return null; } catch (Exception e) { throw asAdapterException("Was not able to resolve policy uid", e, context); } }  @Override String execute(NessusAdapterConfig config,AdapterRuntimeContext runtimeContext); @Override int getAdapterVersion();  }