@Test public void testisAllApplicationsExisting() throws Exception { ConfigPropertyRequest configPropertyRequest = new ConfigPropertyRequest(); List<ConfigPropertyItem> configPropertyItemList = new ArrayList<>(); ConfigPropertyItem item = new ConfigPropertyItem(); item.setApplication("dummy"); configPropertyItemList.add(item); configPropertyRequest.setConfigProperties(configPropertyItemList); List<ConfigPropertyRelation> relList = new ArrayList<>(); ConfigPropertyRelation rel = new ConfigPropertyRelation(); rel.setApplication("dummy"); rel.setParent("dummy"); relList.add(rel); when(configRelationRepository.findAll()).thenReturn(relList ); assertTrue(configPropertyService.isAllApplicationsExisting(configPropertyRequest) == true); }
@Override public boolean isAllApplicationsExisting(ConfigPropertyRequest configPropertyRequest) throws Exception { List<String> invalidApplications = new ArrayList<>(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); }); configPropertyRequest.getConfigProperties().forEach(configPropertyItem -> { if (!applicationParentMap.containsKey(configPropertyItem.getApplication())) { invalidApplications.add(configPropertyItem.getApplication()); } }); return invalidApplications.isEmpty(); }
ConfigPropertyServiceImpl implements ConfigPropertyService { @Override public boolean isAllApplicationsExisting(ConfigPropertyRequest configPropertyRequest) throws Exception { List<String> invalidApplications = new ArrayList<>(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); }); configPropertyRequest.getConfigProperties().forEach(configPropertyItem -> { if (!applicationParentMap.containsKey(configPropertyItem.getApplication())) { invalidApplications.add(configPropertyItem.getApplication()); } }); return invalidApplications.isEmpty(); } }
ConfigPropertyServiceImpl implements ConfigPropertyService { @Override public boolean isAllApplicationsExisting(ConfigPropertyRequest configPropertyRequest) throws Exception { List<String> invalidApplications = new ArrayList<>(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); }); configPropertyRequest.getConfigProperties().forEach(configPropertyItem -> { if (!applicationParentMap.containsKey(configPropertyItem.getApplication())) { invalidApplications.add(configPropertyItem.getApplication()); } }); return invalidApplications.isEmpty(); }  }
ConfigPropertyServiceImpl implements ConfigPropertyService { @Override public boolean isAllApplicationsExisting(ConfigPropertyRequest configPropertyRequest) throws Exception { List<String> invalidApplications = new ArrayList<>(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); }); configPropertyRequest.getConfigProperties().forEach(configPropertyItem -> { if (!applicationParentMap.containsKey(configPropertyItem.getApplication())) { invalidApplications.add(configPropertyItem.getApplication()); } }); return invalidApplications.isEmpty(); }  @Override ConfigTreeNode listProperties(); @Override @Transactional List<ConfigProperty> addUpdateProperties(ConfigPropertyRequest configPropertyRequest, String user,
			String userMessage, String timeNow, boolean partOfRollbackOperation); @Override @Transactional String deleteProperty(ConfigPropertyItem configPropertyItem, String user, String userMessage, String timeNow,
			boolean partOfRollbackOperation); @Override boolean isAllPropertiesExisting(ConfigPropertyRequest configPropertyRequest); @Override boolean isAnyPropertyExisting(ConfigPropertyRequest configPropertyRequest); @Override boolean isPropertyExisting(ConfigPropertyItem configPropertyItem); @Override boolean isCfkeyExisting(String cfkey); @Override boolean isAllCfkeysExisting(ConfigPropertyRequest configPropertyRequest); @Override boolean isApplicationExisting(String application); @Override boolean isAllApplicationsExisting(ConfigPropertyRequest configPropertyRequest); @Override List<String> listAllKeys(); @Override ConfigPropertyAuditTrail listAllConfigPropertyAudits(String timestamp); @Override ConfigPropertyRollbackPreview getRollbackPreview(String timestamp); @Override @Transactional String doConfigPropertyRollbackToTimestamp(String timestamp, String user, String userMessage); @Override List<ConfigProperty> listProperty(String cfkey, String application); }
ConfigPropertyServiceImpl implements ConfigPropertyService { @Override public boolean isAllApplicationsExisting(ConfigPropertyRequest configPropertyRequest) throws Exception { List<String> invalidApplications = new ArrayList<>(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); }); configPropertyRequest.getConfigProperties().forEach(configPropertyItem -> { if (!applicationParentMap.containsKey(configPropertyItem.getApplication())) { invalidApplications.add(configPropertyItem.getApplication()); } }); return invalidApplications.isEmpty(); }  @Override ConfigTreeNode listProperties(); @Override @Transactional List<ConfigProperty> addUpdateProperties(ConfigPropertyRequest configPropertyRequest, String user,
			String userMessage, String timeNow, boolean partOfRollbackOperation); @Override @Transactional String deleteProperty(ConfigPropertyItem configPropertyItem, String user, String userMessage, String timeNow,
			boolean partOfRollbackOperation); @Override boolean isAllPropertiesExisting(ConfigPropertyRequest configPropertyRequest); @Override boolean isAnyPropertyExisting(ConfigPropertyRequest configPropertyRequest); @Override boolean isPropertyExisting(ConfigPropertyItem configPropertyItem); @Override boolean isCfkeyExisting(String cfkey); @Override boolean isAllCfkeysExisting(ConfigPropertyRequest configPropertyRequest); @Override boolean isApplicationExisting(String application); @Override boolean isAllApplicationsExisting(ConfigPropertyRequest configPropertyRequest); @Override List<String> listAllKeys(); @Override ConfigPropertyAuditTrail listAllConfigPropertyAudits(String timestamp); @Override ConfigPropertyRollbackPreview getRollbackPreview(String timestamp); @Override @Transactional String doConfigPropertyRollbackToTimestamp(String timestamp, String user, String userMessage); @Override List<ConfigProperty> listProperty(String cfkey, String application);  }