### Question:
PublicEnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> { @Override public Map<String, Object> invoke() { return filterOutNonPublicProperties(environmentEndpoint.invoke()); } PublicEnvironmentEndpoint(final EnvironmentEndpoint environmentEndpoint,
                                     @Value("${endpoints.pubenv.enabled:false}") final Boolean enabled,
                                     @Value("${endpoints.pubenv.sensitive:true}") final Boolean sensitive,
                                     Environment env); @Override Map<String, Object> invoke();  }### Answer:
@Test void invoke() { when(env.getProperty("notAGroup2.public")).thenReturn("false"); when(env.getProperty("notAGroup3")).thenReturn("aefsd"); when(env.getProperty("notAGroup3.public")).thenReturn("true"); when(env.getProperty("aszgf.dsads")).thenReturn("sdf"); when(env.getProperty("aszgf.dsads.public")).thenReturn("true"); when(env.getProperty("group1.public")).thenReturn("false"); when(env.getProperty("vxvdf.dscvds.ad")).thenReturn("wqwe"); when(env.getProperty("vxvdf.dscvds.ad.public")).thenReturn("true"); when(env.getProperty("wdoij.oijda.acs")).thenReturn("efsef"); when(env.getProperty("wdoij.oijda.acs.public")).thenReturn("true"); when(env.getProperty("cgv.fgchv.dwf")).thenReturn("kjhg"); when(env.getProperty("cgv.fgchv.dwf.public")).thenReturn("true"); final Map<String, Object> envProperties = MapBuilder.<String, Object>builder() .put("notAGroup", "hgfjk") .put("notAGroup2", "hxfgcj") .put("notAGroup2.public", "false") .put("notAGroup3", "aefsd") .put("notAGroup3.public", "true") .put("group1", MapBuilder.<String, Object>builder() .put("sfdfsd.dfsfd.sdfsd", "aefg") .put("aszgf.dsads", "sdf") .put("aszgf.dsads.public", "true") .build()) .put("group2", MapBuilder.<String, Object>builder() .put("vxvdf.dscvds.ad", "wqwe") .put("wdoij.oijda.acs", "efsef") .put("aszgf.dsads", "blah") .put("wdoij.oijda.acs.public", "true") .build()) .put("group3", MapBuilder.<String, Object>builder() .put("ghfcv.jhgk", "khgj") .put("cgv.fgchv.dwf", "kjhg") .put("cgv.fgchv.dwf.public", "true") .build()) .build(); when(environmentEndpoint.invoke()).thenReturn(envProperties); final Map<String, Object> result = endpoint.invoke(); assertThat(result).isEqualTo(MapBuilder.<String, Object>builder() .put("notAGroup3", "aefsd") .put("aszgf.dsads", "sdf") .put("wdoij.oijda.acs", "efsef") .put("cgv.fgchv.dwf", "kjhg") .build()); }
@Test void overwritten() { when(env.getProperty("network")).thenReturn("kovan"); when(env.getProperty("network.public")).thenReturn("true"); final Map<String, Object> envProperties = MapBuilder.<String, Object>builder() .put("network", "kovan") .put("network", "main") .put("network.public", "true") .build(); when(environmentEndpoint.invoke()).thenReturn(envProperties); final Map<String, Object> result = endpoint.invoke(); assertThat(result).isEqualTo(MapBuilder.<String, Object>builder() .put("network", "kovan") .build()); }