TaupageYamlUtil { public static TaupageYaml parseTaupageYaml(String payload) { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); try { return mapper.readValue(payload, TaupageYaml.class); } catch (IOException e) { LOG.warn("Could not parse taupage yaml: {}", e.toString()); return null; } } private  TaupageYamlUtil(); static TaupageYaml parseTaupageYaml(String payload);  }
@Test public void parseTaupageYaml() throws Exception { final TaupageYaml taupageYaml = TaupageYamlUtil.parseTaupageYaml(loadContent("/taupage01.yaml")); assertThat(taupageYaml).isNotNull(); assertThat(taupageYaml.getApplicationId()).isEqualTo("fullstop"); assertThat(taupageYaml.getApplicationVersion()).isEqualTo("5"); }
@Test public void testParseMissingAppVersion() throws Exception { final TaupageYaml taupageYaml = TaupageYamlUtil.parseTaupageYaml(loadContent("/taupage-missing-app-version.yaml")); assertThat(taupageYaml).isNotNull(); assertThat(taupageYaml.getApplicationId()).isEqualTo("fullstop"); assertThat(taupageYaml.getApplicationVersion()).isNull(); }
@Test public void testParseEmptyYaml() throws Exception { final TaupageYaml taupageYaml = TaupageYamlUtil.parseTaupageYaml(""); assertThat(taupageYaml).isNull(); }
@Test public void testParseInvalidYaml() throws Exception { final TaupageYaml taupageYaml = TaupageYamlUtil.parseTaupageYaml("'foo'"); assertThat(taupageYaml).isNull(); }