LinkBean implements JsonBean { @SuppressWarnings("unchecked") @Override public JSONObject extract(boolean skipSensitive) { JSONObject link = new JSONObject(); link.put(LINK, extractLink(skipSensitive, links.get(0))); return link; } LinkBean(MLink link);  LinkBean(List<MLink> links);  LinkBean(); void addConnectorConfigBundle(Long id, ResourceBundle connectorConfigBundle); boolean hasConnectorConfigBundle(Long id); List<MLink> getLinks(); ResourceBundle getConnectorConfigBundle(Long id); @SuppressWarnings("unchecked") @Override JSONObject extract(boolean skipSensitive); @Override void restore(JSONObject jsonObject);  }
@Test public void testSensitivityFilter() { Date created = new Date(); Date updated = new Date(); MLink link = BeanTestUtil.createLink("ahoj", "link1", 22L, created, updated); MStringInput input = (MStringInput) link.getConnectorLinkConfig().getConfigs().get(0) .getInputs().get(0); input.setValue("Hi there!"); LinkBean bean = new LinkBean(link); JSONObject json = bean.extract(false); JSONObject jsonFiltered = bean.extract(true); JSONObject linkObj = (JSONObject) json.get(LinkBean.LINK); JSONArray linkConfigsObj = (JSONArray) linkObj.get(LinkBean.LINK_CONFIG_VALUES); JSONObject linkConfigObj = (JSONObject) linkConfigsObj.get(0); JSONArray inputs = (JSONArray) linkConfigObj.get(ConfigInputConstants.CONFIG_INPUTS); assertEquals(3, inputs.size()); JSONObject password = (JSONObject) inputs.get(2); assertTrue(password.containsKey(ConfigInputConstants.CONFIG_INPUT_VALUE)); linkObj = (JSONObject) jsonFiltered.get(LinkBean.LINK); linkConfigsObj = (JSONArray) linkObj.get(LinkBean.LINK_CONFIG_VALUES); linkConfigObj = (JSONObject) linkConfigsObj.get(0); inputs = (JSONArray) linkConfigObj.get(ConfigInputConstants.CONFIG_INPUTS); assertEquals(3, inputs.size()); password = (JSONObject) inputs.get(2); assertFalse(password.containsKey(ConfigInputConstants.CONFIG_INPUT_VALUE)); }