@Test public void engine_configurations_can_be_extracted() throws AdapterException { String json_data = "[\n" + " {\n" + " \"id\": 1,\n" + " \"name\": \"Default Configuration\"\n" + " },\n" + " {\n" + " \"id\": 2,\n" + " \"name\": \"Japanese (Shift-JIS)\"\n" + " },\n" + " {\n" + " \"id\": 3,\n" + " \"name\": \"Korean\"\n" + " },\n" + " {\n" + " \"id\": 5,\n" + " \"name\": \"Multi-language Scan\"\n" + " }\n" + " ]"; CheckmarxEngineConfiguration multiLanguageScanConfiguration = new CheckmarxEngineConfiguration(); multiLanguageScanConfiguration.setId(5L); multiLanguageScanConfiguration.setName(CheckmarxConstants.DEFAULT_CHECKMARX_ENGINECONFIGURATION_MULTILANGANGE_SCAN_NAME); List<CheckmarxEngineConfiguration> engineConfigurations = supportToTest.extractEngineConfigurationsFromGet(json_data, JSONAdapterSupport.FOR_UNKNOWN_ADAPTER); assertThat(engineConfigurations, notNullValue()); assertThat(engineConfigurations, not(empty())); assertThat(engineConfigurations, hasSize(4)); assertThat(engineConfigurations, hasItem(multiLanguageScanConfiguration)); }
protected List<CheckmarxEngineConfiguration> extractEngineConfigurationsFromGet(String json, JSONAdapterSupport support) throws AdapterException { Access rootNode = support.fetchRootNode(json); List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>(); for (JsonNode node : rootNode.asArray()) { CheckmarxEngineConfiguration engineConfiguration = new CheckmarxEngineConfiguration(); engineConfiguration.setId(node.get("id").asLong()); engineConfiguration.setName(node.get("name").asText()); engineConfigurations.add(engineConfiguration); } return engineConfigurations; }
CheckmarxProjectSupport { protected List<CheckmarxEngineConfiguration> extractEngineConfigurationsFromGet(String json, JSONAdapterSupport support) throws AdapterException { Access rootNode = support.fetchRootNode(json); List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>(); for (JsonNode node : rootNode.asArray()) { CheckmarxEngineConfiguration engineConfiguration = new CheckmarxEngineConfiguration(); engineConfiguration.setId(node.get("id").asLong()); engineConfiguration.setName(node.get("name").asText()); engineConfigurations.add(engineConfiguration); } return engineConfigurations; } }
CheckmarxProjectSupport { protected List<CheckmarxEngineConfiguration> extractEngineConfigurationsFromGet(String json, JSONAdapterSupport support) throws AdapterException { Access rootNode = support.fetchRootNode(json); List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>(); for (JsonNode node : rootNode.asArray()) { CheckmarxEngineConfiguration engineConfiguration = new CheckmarxEngineConfiguration(); engineConfiguration.setId(node.get("id").asLong()); engineConfiguration.setName(node.get("name").asText()); engineConfigurations.add(engineConfiguration); } return engineConfigurations; }  }
CheckmarxProjectSupport { protected List<CheckmarxEngineConfiguration> extractEngineConfigurationsFromGet(String json, JSONAdapterSupport support) throws AdapterException { Access rootNode = support.fetchRootNode(json); List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>(); for (JsonNode node : rootNode.asArray()) { CheckmarxEngineConfiguration engineConfiguration = new CheckmarxEngineConfiguration(); engineConfiguration.setId(node.get("id").asLong()); engineConfiguration.setName(node.get("name").asText()); engineConfigurations.add(engineConfiguration); } return engineConfigurations; }  void ensureProjectExists(CheckmarxContext context); }
CheckmarxProjectSupport { protected List<CheckmarxEngineConfiguration> extractEngineConfigurationsFromGet(String json, JSONAdapterSupport support) throws AdapterException { Access rootNode = support.fetchRootNode(json); List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>(); for (JsonNode node : rootNode.asArray()) { CheckmarxEngineConfiguration engineConfiguration = new CheckmarxEngineConfiguration(); engineConfiguration.setId(node.get("id").asLong()); engineConfiguration.setName(node.get("name").asText()); engineConfigurations.add(engineConfiguration); } return engineConfigurations; }  void ensureProjectExists(CheckmarxContext context);  }