@Test public void testDeleteLookupFromExtLookups() throws Exception { String lookupName = "lookupName"; Boolean readonlyExt = false; String lookups = "{\"inverseValuesLookup\": [], \"nestedLookup\": [], \"standardLookup\": []}"; String lookupNameTmp = "lookupNameTmp"; Boolean readonlyExTmp = false; String extLookups = "{\"standardLookup\":[{\"name\":\"" + lookupName + "\",\"entries\":[],\"readonly\":\"" + readonlyExt + "\"},{\"name\":\"" + lookupNameTmp + "\",\"entries\":[],\"readonly\":\"" + readonlyExTmp + "\"}]}"; configLookupDao.setLookups(lookups); configLookupDao.setLookupsExt(extLookups); String returnedLookups = configLookupDao.deleteLookup(lookupName); ArrayNode returnedLookup = JsonPath.using(configuration).parse(returnedLookups) .read("$.standardLookup..[?(@.name=='" + lookupName + "')]"); assertEquals(0, returnedLookup.size()); }
private void deleteLookupFromExtLookups(String lookupName) throws IOException { String updatedLookupsAsJson = null; for (LookupType lookupType : LookupType.values()) { ArrayNode jsonArrayExt = JsonPath.using(configurationWithSuppressedExceptions).parse(lookupsExt) .read("$." + lookupType.getTypeName()); if (jsonArrayExt != null) { for (int i = 0; i < jsonArrayExt.size(); i++) { JsonNode node = jsonArrayExt.get(i); if (lookupName.equals(node.get("name").asText())) { jsonArrayExt.remove(i); updatedLookupsAsJson = JsonPath.using(configuration).parse(lookupsExt) .set("$." + lookupType.getTypeName(), jsonArrayExt).jsonString(); break; } } } } saveLookupsExt(updatedLookupsAsJson); }
ConfigLookupDao implements LookupDao { private void deleteLookupFromExtLookups(String lookupName) throws IOException { String updatedLookupsAsJson = null; for (LookupType lookupType : LookupType.values()) { ArrayNode jsonArrayExt = JsonPath.using(configurationWithSuppressedExceptions).parse(lookupsExt) .read("$." + lookupType.getTypeName()); if (jsonArrayExt != null) { for (int i = 0; i < jsonArrayExt.size(); i++) { JsonNode node = jsonArrayExt.get(i); if (lookupName.equals(node.get("name").asText())) { jsonArrayExt.remove(i); updatedLookupsAsJson = JsonPath.using(configuration).parse(lookupsExt) .set("$." + lookupType.getTypeName(), jsonArrayExt).jsonString(); break; } } } } saveLookupsExt(updatedLookupsAsJson); } }
ConfigLookupDao implements LookupDao { private void deleteLookupFromExtLookups(String lookupName) throws IOException { String updatedLookupsAsJson = null; for (LookupType lookupType : LookupType.values()) { ArrayNode jsonArrayExt = JsonPath.using(configurationWithSuppressedExceptions).parse(lookupsExt) .read("$." + lookupType.getTypeName()); if (jsonArrayExt != null) { for (int i = 0; i < jsonArrayExt.size(); i++) { JsonNode node = jsonArrayExt.get(i); if (lookupName.equals(node.get("name").asText())) { jsonArrayExt.remove(i); updatedLookupsAsJson = JsonPath.using(configuration).parse(lookupsExt) .set("$." + lookupType.getTypeName(), jsonArrayExt).jsonString(); break; } } } } saveLookupsExt(updatedLookupsAsJson); }  }
ConfigLookupDao implements LookupDao { private void deleteLookupFromExtLookups(String lookupName) throws IOException { String updatedLookupsAsJson = null; for (LookupType lookupType : LookupType.values()) { ArrayNode jsonArrayExt = JsonPath.using(configurationWithSuppressedExceptions).parse(lookupsExt) .read("$." + lookupType.getTypeName()); if (jsonArrayExt != null) { for (int i = 0; i < jsonArrayExt.size(); i++) { JsonNode node = jsonArrayExt.get(i); if (lookupName.equals(node.get("name").asText())) { jsonArrayExt.remove(i); updatedLookupsAsJson = JsonPath.using(configuration).parse(lookupsExt) .set("$." + lookupType.getTypeName(), jsonArrayExt).jsonString(); break; } } } } saveLookupsExt(updatedLookupsAsJson); }  @Override AcmLookup<?> getLookupByName(String name); @Override String getMergedLookups(); @Override synchronized String saveLookup(LookupDefinition lookupDefinition); @Override String deleteLookup(String name); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter converter); String getLookups(); void setLookups(String lookups); String getLookupsExt(); void setLookupsExt(String lookupsExt); String getLookupsExtFileLocation(); void setLookupsExtFileLocation(String lookupsExtFileLocation); }
ConfigLookupDao implements LookupDao { private void deleteLookupFromExtLookups(String lookupName) throws IOException { String updatedLookupsAsJson = null; for (LookupType lookupType : LookupType.values()) { ArrayNode jsonArrayExt = JsonPath.using(configurationWithSuppressedExceptions).parse(lookupsExt) .read("$." + lookupType.getTypeName()); if (jsonArrayExt != null) { for (int i = 0; i < jsonArrayExt.size(); i++) { JsonNode node = jsonArrayExt.get(i); if (lookupName.equals(node.get("name").asText())) { jsonArrayExt.remove(i); updatedLookupsAsJson = JsonPath.using(configuration).parse(lookupsExt) .set("$." + lookupType.getTypeName(), jsonArrayExt).jsonString(); break; } } } } saveLookupsExt(updatedLookupsAsJson); }  @Override AcmLookup<?> getLookupByName(String name); @Override String getMergedLookups(); @Override synchronized String saveLookup(LookupDefinition lookupDefinition); @Override String deleteLookup(String name); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter converter); String getLookups(); void setLookups(String lookups); String getLookupsExt(); void setLookupsExt(String lookupsExt); String getLookupsExtFileLocation(); void setLookupsExtFileLocation(String lookupsExtFileLocation);  }