@Test public void shouldCompareOnlyReadOnlyLookups() { LookupDto lookupDto = new LookupDto("lookupName", true, true, new ArrayList<LookupFieldDto>(), true, "methodName", new ArrayList<String>()); LookupDto lookupDto2 = new LookupDto(); lookupDto2.setReadOnly(false); entityLookups = asList(lookupDto, lookupDto2); newLookups = asList(lookupDto); when(entityService.getEntityLookups(ENTITY_ID)).thenReturn(entityLookups); boolean lookupsDiffer = schemaComparator.lookupsDiffer(ENTITY_ID, newLookups); assertFalse(lookupsDiffer); }
public boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups) { List<LookupDto> existingLookups = entityService.getEntityLookups(entityId); Map<String, LookupDto> entityLookupsMappings = new HashMap<>(); for (LookupDto entityLookup : existingLookups) { if (entityLookup.isReadOnly()) { entityLookupsMappings.put(entityLookup.getLookupName(), entityLookup); } } if (entityLookupsMappings.size() != newLookups.size()) { return true; } for (LookupDto lookup : newLookups) { if (!lookupEquals(lookup, entityLookupsMappings.get(lookup.getLookupName()))) { return true; } } return false; }
SchemaComparator { public boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups) { List<LookupDto> existingLookups = entityService.getEntityLookups(entityId); Map<String, LookupDto> entityLookupsMappings = new HashMap<>(); for (LookupDto entityLookup : existingLookups) { if (entityLookup.isReadOnly()) { entityLookupsMappings.put(entityLookup.getLookupName(), entityLookup); } } if (entityLookupsMappings.size() != newLookups.size()) { return true; } for (LookupDto lookup : newLookups) { if (!lookupEquals(lookup, entityLookupsMappings.get(lookup.getLookupName()))) { return true; } } return false; } }
SchemaComparator { public boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups) { List<LookupDto> existingLookups = entityService.getEntityLookups(entityId); Map<String, LookupDto> entityLookupsMappings = new HashMap<>(); for (LookupDto entityLookup : existingLookups) { if (entityLookup.isReadOnly()) { entityLookupsMappings.put(entityLookup.getLookupName(), entityLookup); } } if (entityLookupsMappings.size() != newLookups.size()) { return true; } for (LookupDto lookup : newLookups) { if (!lookupEquals(lookup, entityLookupsMappings.get(lookup.getLookupName()))) { return true; } } return false; }  }
SchemaComparator { public boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups) { List<LookupDto> existingLookups = entityService.getEntityLookups(entityId); Map<String, LookupDto> entityLookupsMappings = new HashMap<>(); for (LookupDto entityLookup : existingLookups) { if (entityLookup.isReadOnly()) { entityLookupsMappings.put(entityLookup.getLookupName(), entityLookup); } } if (entityLookupsMappings.size() != newLookups.size()) { return true; } for (LookupDto lookup : newLookups) { if (!lookupEquals(lookup, entityLookupsMappings.get(lookup.getLookupName()))) { return true; } } return false; }  boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups); @Autowired void setEntityService(EntityService entityService); }
SchemaComparator { public boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups) { List<LookupDto> existingLookups = entityService.getEntityLookups(entityId); Map<String, LookupDto> entityLookupsMappings = new HashMap<>(); for (LookupDto entityLookup : existingLookups) { if (entityLookup.isReadOnly()) { entityLookupsMappings.put(entityLookup.getLookupName(), entityLookup); } } if (entityLookupsMappings.size() != newLookups.size()) { return true; } for (LookupDto lookup : newLookups) { if (!lookupEquals(lookup, entityLookupsMappings.get(lookup.getLookupName()))) { return true; } } return false; }  boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups); @Autowired void setEntityService(EntityService entityService);  }