@Test public void listPropertiesTest() throws Exception { List<ConfigProperty> cfList = new ArrayList<>(); ConfigProperty cf1 = new ConfigProperty(); ConfigPropertyKey cfkey1 = new ConfigPropertyKey(); cfkey1.setApplication("application"); cfkey1.setCfkey("applevelkey1"); cfkey1.setProfile("dev"); cf1.setConfigKeyParams(cfkey1); cf1.setValue("applevelvalue"); cfList.add(cf1); ConfigProperty cf2 = new ConfigProperty(); ConfigPropertyKey cfkey2 = new ConfigPropertyKey(); cfkey2.setApplication("application"); cfkey2.setCfkey("applevelkey2"); cfkey2.setProfile("dev"); cf2.setConfigKeyParams(cfkey2); cf2.setValue("applevelvalue"); cfList.add(cf2); ConfigProperty cf3 = new ConfigProperty(); ConfigPropertyKey cfkey3 = new ConfigPropertyKey(); cfkey3.setApplication("api"); cfkey3.setCfkey("applevelkey3"); cfkey3.setProfile("dev"); cf3.setConfigKeyParams(cfkey3); cf3.setValue("applevelvalue"); cfList.add(cf3); ConfigProperty cf4 = new ConfigProperty(); ConfigPropertyKey cfkey4 = new ConfigPropertyKey(); cfkey4.setApplication("api"); cfkey4.setCfkey("applevelkey4"); cfkey4.setProfile("dev"); cf4.setConfigKeyParams(cfkey4); cf4.setValue("applevelvalue"); cfList.add(cf4); ConfigProperty cf5 = new ConfigProperty(); ConfigPropertyKey cfkey5 = new ConfigPropertyKey(); cfkey5.setApplication("api"); cfkey5.setCfkey("applevelkey5"); cfkey5.setProfile("dev"); cf5.setConfigKeyParams(cfkey5); cf5.setValue("applevelvalue"); cfList.add(cf5); when(configPropertyRepository.findAll()).thenReturn(cfList); List<ConfigPropertyRelation> relationlist = new ArrayList<>(); ConfigPropertyRelation relation1 = new ConfigPropertyRelation(); relation1.setApplication("application"); relation1.setParent("root"); relationlist.add(relation1); ConfigPropertyRelation relation2 = new ConfigPropertyRelation(); relation2.setApplication("api"); relation2.setParent("application"); relationlist.add(relation2); ConfigPropertyRelation relation3 = new ConfigPropertyRelation(); relation3.setApplication("asset-service"); relation3.setParent("api"); relationlist.add(relation3); when(configRelationRepository.findAll()).thenReturn(relationlist); List<ConfigPropertyMetadata> cfMetaList = new ArrayList<>(); ConfigPropertyMetadata meta1 = new ConfigPropertyMetadata(); meta1.setCfkey("applevelkey1"); meta1.setDescription("desc"); cfMetaList.add(meta1); ConfigPropertyMetadata meta2 = new ConfigPropertyMetadata(); meta2.setCfkey("applevelkey2"); meta2.setDescription("desc"); cfMetaList.add(meta2); ConfigPropertyMetadata meta3 = new ConfigPropertyMetadata(); meta3.setCfkey("applevelkey3"); meta3.setDescription("desc"); cfMetaList.add(meta3); ConfigPropertyMetadata meta4 = new ConfigPropertyMetadata(); meta4.setCfkey("applevelkey4"); meta4.setDescription("desc"); cfMetaList.add(meta4); ConfigPropertyMetadata meta5 = new ConfigPropertyMetadata(); meta5.setCfkey("applevelkey5"); meta5.setDescription("desc"); cfMetaList.add(meta5); when(configPropertyMetadataRepository.findAll()).thenReturn(cfMetaList); assertTrue((configPropertyService.listProperties().getProperties().size() == 2)); assertTrue((configPropertyService.listProperties().getChildren().size() == 1)); }
@Override public ConfigTreeNode listProperties() throws Exception { List<ConfigProperty> configPropertyList = configPropertyRepository.findAll(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); List<ConfigPropertyMetadata> configMetadataList = configPropertyMetadataRepository.findAll(); List<String> rootNode = new ArrayList<>(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); if ("root".equals(configRelation.getParent())) { rootNode.add(configRelation.getApplication()); } }); ConfigTreeNode treeNode = new ConfigTreeNode(); treeNode.setName(rootNode.get(0)); populateNode(treeNode, applicationParentMap, configPropertyList, configMetadataList); return treeNode; }
ConfigPropertyServiceImpl implements ConfigPropertyService { @Override public ConfigTreeNode listProperties() throws Exception { List<ConfigProperty> configPropertyList = configPropertyRepository.findAll(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); List<ConfigPropertyMetadata> configMetadataList = configPropertyMetadataRepository.findAll(); List<String> rootNode = new ArrayList<>(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); if ("root".equals(configRelation.getParent())) { rootNode.add(configRelation.getApplication()); } }); ConfigTreeNode treeNode = new ConfigTreeNode(); treeNode.setName(rootNode.get(0)); populateNode(treeNode, applicationParentMap, configPropertyList, configMetadataList); return treeNode; } }
ConfigPropertyServiceImpl implements ConfigPropertyService { @Override public ConfigTreeNode listProperties() throws Exception { List<ConfigProperty> configPropertyList = configPropertyRepository.findAll(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); List<ConfigPropertyMetadata> configMetadataList = configPropertyMetadataRepository.findAll(); List<String> rootNode = new ArrayList<>(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); if ("root".equals(configRelation.getParent())) { rootNode.add(configRelation.getApplication()); } }); ConfigTreeNode treeNode = new ConfigTreeNode(); treeNode.setName(rootNode.get(0)); populateNode(treeNode, applicationParentMap, configPropertyList, configMetadataList); return treeNode; }  }
ConfigPropertyServiceImpl implements ConfigPropertyService { @Override public ConfigTreeNode listProperties() throws Exception { List<ConfigProperty> configPropertyList = configPropertyRepository.findAll(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); List<ConfigPropertyMetadata> configMetadataList = configPropertyMetadataRepository.findAll(); List<String> rootNode = new ArrayList<>(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); if ("root".equals(configRelation.getParent())) { rootNode.add(configRelation.getApplication()); } }); ConfigTreeNode treeNode = new ConfigTreeNode(); treeNode.setName(rootNode.get(0)); populateNode(treeNode, applicationParentMap, configPropertyList, configMetadataList); return treeNode; }  @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 ConfigTreeNode listProperties() throws Exception { List<ConfigProperty> configPropertyList = configPropertyRepository.findAll(); List<ConfigPropertyRelation> configRelationList = configPropertyRelationRepository.findAll(); List<ConfigPropertyMetadata> configMetadataList = configPropertyMetadataRepository.findAll(); List<String> rootNode = new ArrayList<>(); Map<String, String> applicationParentMap = new HashMap<>(); configRelationList.forEach(configRelation -> { applicationParentMap.put(configRelation.getApplication(), configRelation.getParent()); if ("root".equals(configRelation.getParent())) { rootNode.add(configRelation.getApplication()); } }); ConfigTreeNode treeNode = new ConfigTreeNode(); treeNode.setName(rootNode.get(0)); populateNode(treeNode, applicationParentMap, configPropertyList, configMetadataList); return treeNode; }  @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);  }