@Test public void ioExceptionWhilePopulatingMetadataShouldBeConvertedToSnitchingException() throws IOException { ObjectMapper objectMapperMock = Mockito.mock(ObjectMapper.class); SystemFragment frag = SystemFragment.empty(); Mockito.when(snitch.snitch()).thenReturn(frag); EurekaMetadataPopulator pop = new EurekaMetadataPopulator(snitch, appInfoManager, props, objectMapperMock); Mockito.when(objectMapperMock.writeValueAsString(frag)) .thenThrow(new JsonEOFException(null, null, "unit test")); try { pop.populate(); Assert.fail("SnitchingException expected"); } catch (SnitchingException e) { Assertions.assertThat(e.getSnitchUri()).isEqualTo(TEST_URI); } }
public void populate() { try { Map<String, String> metadata = appInfoManager.getEurekaInstanceConfig().getMetadataMap(); metadata.put(CereebroMetadata.KEY_SNITCH_URI, getEndpointUri().toString()); String frag = objectMapper.writeValueAsString(snitch.snitch()); metadata.put(CereebroMetadata.KEY_SNITCH_SYSTEM_FRAGMENT_JSON, frag); appInfoManager.registerAppMetadata(metadata); } catch (IOException e) { throw new SnitchingException(snitch.getUri(), "Error while serializing fragment", e); } }
EurekaMetadataPopulator { public void populate() { try { Map<String, String> metadata = appInfoManager.getEurekaInstanceConfig().getMetadataMap(); metadata.put(CereebroMetadata.KEY_SNITCH_URI, getEndpointUri().toString()); String frag = objectMapper.writeValueAsString(snitch.snitch()); metadata.put(CereebroMetadata.KEY_SNITCH_SYSTEM_FRAGMENT_JSON, frag); appInfoManager.registerAppMetadata(metadata); } catch (IOException e) { throw new SnitchingException(snitch.getUri(), "Error while serializing fragment", e); } } }
EurekaMetadataPopulator { public void populate() { try { Map<String, String> metadata = appInfoManager.getEurekaInstanceConfig().getMetadataMap(); metadata.put(CereebroMetadata.KEY_SNITCH_URI, getEndpointUri().toString()); String frag = objectMapper.writeValueAsString(snitch.snitch()); metadata.put(CereebroMetadata.KEY_SNITCH_SYSTEM_FRAGMENT_JSON, frag); appInfoManager.registerAppMetadata(metadata); } catch (IOException e) { throw new SnitchingException(snitch.getUri(), "Error while serializing fragment", e); } } EurekaMetadataPopulator(SnitchEndpoint snitch, ApplicationInfoManager manager,
            EurekaInstanceSnitchProperties props, ObjectMapper mapper); }
EurekaMetadataPopulator { public void populate() { try { Map<String, String> metadata = appInfoManager.getEurekaInstanceConfig().getMetadataMap(); metadata.put(CereebroMetadata.KEY_SNITCH_URI, getEndpointUri().toString()); String frag = objectMapper.writeValueAsString(snitch.snitch()); metadata.put(CereebroMetadata.KEY_SNITCH_SYSTEM_FRAGMENT_JSON, frag); appInfoManager.registerAppMetadata(metadata); } catch (IOException e) { throw new SnitchingException(snitch.getUri(), "Error while serializing fragment", e); } } EurekaMetadataPopulator(SnitchEndpoint snitch, ApplicationInfoManager manager,
            EurekaInstanceSnitchProperties props, ObjectMapper mapper); void populate(); }
EurekaMetadataPopulator { public void populate() { try { Map<String, String> metadata = appInfoManager.getEurekaInstanceConfig().getMetadataMap(); metadata.put(CereebroMetadata.KEY_SNITCH_URI, getEndpointUri().toString()); String frag = objectMapper.writeValueAsString(snitch.snitch()); metadata.put(CereebroMetadata.KEY_SNITCH_SYSTEM_FRAGMENT_JSON, frag); appInfoManager.registerAppMetadata(metadata); } catch (IOException e) { throw new SnitchingException(snitch.getUri(), "Error while serializing fragment", e); } } EurekaMetadataPopulator(SnitchEndpoint snitch, ApplicationInfoManager manager,
            EurekaInstanceSnitchProperties props, ObjectMapper mapper); void populate();  }