@Test public void testUpdateMetaData() { final String updatedMetaData = "{\"updated\":\"meta-data\"}"; final String resourceName = "update-my-meta-data.txt"; Group mockGroup = mock(Group.class); Jvm mockJvm = mock(Jvm.class); Set<Jvm> groupSet = new HashSet<>(); groupSet.add(mockJvm); when(mockGroup.getJvms()).thenReturn(groupSet); when(mockJvm.getJvmName()).thenReturn("jvm-name"); when(mockGroupPersistence.getGroup(anyString())).thenReturn(mockGroup); when(mockGroupPersistence.updateGroupJvmResourceMetaData(anyString(), anyString(), anyString())).thenReturn(updatedMetaData); groupLevelJvmResourceHandler.updateResourceMetaData(resourceIdentifier, resourceName, updatedMetaData); verify(mockGroupPersistence).updateGroupJvmResourceMetaData(eq(resourceIdentifier.groupName), eq(resourceName), eq(updatedMetaData)); verify(mockJvmPersistence).updateResourceMetaData(eq(mockJvm.getJvmName()), eq(resourceName), eq(updatedMetaData)); }
@Override public String updateResourceMetaData(ResourceIdentifier resourceIdentifier, String resourceName, String metaData) { if (canHandle(resourceIdentifier)) { final String updatedMetaData = groupPersistenceService.updateGroupJvmResourceMetaData(resourceIdentifier.groupName, resourceName, metaData); Set<Jvm> jvmSet = groupPersistenceService.getGroup(resourceIdentifier.groupName).getJvms(); for (Jvm jvm : jvmSet) { jvmPersistenceService.updateResourceMetaData(jvm.getJvmName(), resourceName, metaData); } return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } }
GroupLevelJvmResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(ResourceIdentifier resourceIdentifier, String resourceName, String metaData) { if (canHandle(resourceIdentifier)) { final String updatedMetaData = groupPersistenceService.updateGroupJvmResourceMetaData(resourceIdentifier.groupName, resourceName, metaData); Set<Jvm> jvmSet = groupPersistenceService.getGroup(resourceIdentifier.groupName).getJvms(); for (Jvm jvm : jvmSet) { jvmPersistenceService.updateResourceMetaData(jvm.getJvmName(), resourceName, metaData); } return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } }
GroupLevelJvmResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(ResourceIdentifier resourceIdentifier, String resourceName, String metaData) { if (canHandle(resourceIdentifier)) { final String updatedMetaData = groupPersistenceService.updateGroupJvmResourceMetaData(resourceIdentifier.groupName, resourceName, metaData); Set<Jvm> jvmSet = groupPersistenceService.getGroup(resourceIdentifier.groupName).getJvms(); for (Jvm jvm : jvmSet) { jvmPersistenceService.updateResourceMetaData(jvm.getJvmName(), resourceName, metaData); } return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } GroupLevelJvmResourceHandler(final ResourceDao resourceDao, final GroupPersistenceService groupPersistenceService,
                                        final JvmPersistenceService jvmPersistenceService, final ResourceHandler successor); }
GroupLevelJvmResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(ResourceIdentifier resourceIdentifier, String resourceName, String metaData) { if (canHandle(resourceIdentifier)) { final String updatedMetaData = groupPersistenceService.updateGroupJvmResourceMetaData(resourceIdentifier.groupName, resourceName, metaData); Set<Jvm> jvmSet = groupPersistenceService.getGroup(resourceIdentifier.groupName).getJvms(); for (Jvm jvm : jvmSet) { jvmPersistenceService.updateResourceMetaData(jvm.getJvmName(), resourceName, metaData); } return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } GroupLevelJvmResourceHandler(final ResourceDao resourceDao, final GroupPersistenceService groupPersistenceService,
                                        final JvmPersistenceService jvmPersistenceService, final ResourceHandler successor); @Override ConfigTemplate fetchResource(final ResourceIdentifier resourceIdentifier); @Override CreateResourceResponseWrapper createResource(final ResourceIdentifier resourceIdentifier,
                                                        final ResourceTemplateMetaData metaData,
                                                        final String templateContent); @Override void deleteResource(final ResourceIdentifier resourceIdentifier); @Override String updateResourceMetaData(ResourceIdentifier resourceIdentifier, String resourceName, String metaData); @Override Object getSelectedValue(ResourceIdentifier resourceIdentifier); @Override List<String> getResourceNames(ResourceIdentifier resourceIdentifier); }
GroupLevelJvmResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(ResourceIdentifier resourceIdentifier, String resourceName, String metaData) { if (canHandle(resourceIdentifier)) { final String updatedMetaData = groupPersistenceService.updateGroupJvmResourceMetaData(resourceIdentifier.groupName, resourceName, metaData); Set<Jvm> jvmSet = groupPersistenceService.getGroup(resourceIdentifier.groupName).getJvms(); for (Jvm jvm : jvmSet) { jvmPersistenceService.updateResourceMetaData(jvm.getJvmName(), resourceName, metaData); } return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } GroupLevelJvmResourceHandler(final ResourceDao resourceDao, final GroupPersistenceService groupPersistenceService,
                                        final JvmPersistenceService jvmPersistenceService, final ResourceHandler successor); @Override ConfigTemplate fetchResource(final ResourceIdentifier resourceIdentifier); @Override CreateResourceResponseWrapper createResource(final ResourceIdentifier resourceIdentifier,
                                                        final ResourceTemplateMetaData metaData,
                                                        final String templateContent); @Override void deleteResource(final ResourceIdentifier resourceIdentifier); @Override String updateResourceMetaData(ResourceIdentifier resourceIdentifier, String resourceName, String metaData); @Override Object getSelectedValue(ResourceIdentifier resourceIdentifier); @Override List<String> getResourceNames(ResourceIdentifier resourceIdentifier);  }