@Test public void getConfig1() throws Exception { expect(mockConfig1.getConfigName()).andReturn("config1"); expect(mockConfig1.getConfigAsJson()).andReturn("{\"some1\":\"value1\"}"); replayAll(); String returned = unit.getConfigAsJson("config1"); verifyAll(); assertNotNull(returned); ObjectMapper om = new ObjectMapper(); JsonNode actualObj = om.readTree(returned); JsonNode someNode = actualObj.path("some1"); String someValue = someNode.textValue(); assertEquals(someValue, "value1"); }
public String getConfigAsJson(String name) { String rc = "{}"; try { Optional<AcmConfig> optionalRcString = configList.stream().filter(x -> x.getConfigName().equals(name)).findFirst(); if (optionalRcString.isPresent()) rc = optionalRcString.get().getConfigAsJson(); } catch (NoSuchElementException e) { log.error(e.getMessage()); } return rc; }
ConfigService { public String getConfigAsJson(String name) { String rc = "{}"; try { Optional<AcmConfig> optionalRcString = configList.stream().filter(x -> x.getConfigName().equals(name)).findFirst(); if (optionalRcString.isPresent()) rc = optionalRcString.get().getConfigAsJson(); } catch (NoSuchElementException e) { log.error(e.getMessage()); } return rc; } }
ConfigService { public String getConfigAsJson(String name) { String rc = "{}"; try { Optional<AcmConfig> optionalRcString = configList.stream().filter(x -> x.getConfigName().equals(name)).findFirst(); if (optionalRcString.isPresent()) rc = optionalRcString.get().getConfigAsJson(); } catch (NoSuchElementException e) { log.error(e.getMessage()); } return rc; }  }
ConfigService { public String getConfigAsJson(String name) { String rc = "{}"; try { Optional<AcmConfig> optionalRcString = configList.stream().filter(x -> x.getConfigName().equals(name)).findFirst(); if (optionalRcString.isPresent()) rc = optionalRcString.get().getConfigAsJson(); } catch (NoSuchElementException e) { log.error(e.getMessage()); } return rc; }  List<Map<String, String>> getInfo(); String getConfigAsJson(String name); List<AcmConfig> getConfigList(); void setConfigList(List<AcmConfig> configList); }
ConfigService { public String getConfigAsJson(String name) { String rc = "{}"; try { Optional<AcmConfig> optionalRcString = configList.stream().filter(x -> x.getConfigName().equals(name)).findFirst(); if (optionalRcString.isPresent()) rc = optionalRcString.get().getConfigAsJson(); } catch (NoSuchElementException e) { log.error(e.getMessage()); } return rc; }  List<Map<String, String>> getInfo(); String getConfigAsJson(String name); List<AcmConfig> getConfigList(); void setConfigList(List<AcmConfig> configList);  }