@Test (expected = GroupLevelAppResourceHandlerException.class) public void testUpdateMetaDataFailsToParseMetaData() { reset(mockResourceDao, mockAppPersistence); final String updatedMetaData = "{\"templateName\":\"test-template-name\", \"contentType\":\"application/zip\", \"deployFileName\":\"test-app.war\", \"deployPath\":\"/fake/deploy/path\", \"entity\":{\"deployToJvms\":false}, \"unpack\":\"true\", \"overwrite\":\"true\"}"; final String resourceName = "update-my-meta-data.txt"; Group mockGroup = mock(Group.class); Set<Jvm> jvmSet = new HashSet<>(); Jvm mockJvm = mock(Jvm.class); jvmSet.add(mockJvm); when(mockJvm.getJvmName()).thenReturn("mockJvm"); when(mockGroup.getJvms()).thenReturn(jvmSet); when(mockGroup.getName()).thenReturn("test-group-name"); when(mockGroupPersistence.updateGroupAppResourceMetaData(anyString(), anyString(), anyString(), anyString())).thenReturn(updatedMetaData); when(mockGroupPersistence.getGroupAppResourceTemplateMetaData(anyString(), anyString(), anyString())).thenReturn("{\"entity\":{},,,}"); when(mockGroupPersistence.getGroup(anyString())).thenReturn(mockGroup); when(mockAppPersistence.getResourceTemplateNames(anyString(), anyString())).thenReturn(Collections.singletonList(resourceName)); Application mockApplication = mock(Application.class); when(mockApplication.getName()).thenReturn("app-name"); when(mockApplication.getId()).thenReturn(new Identifier<Application>(1111L)); when(mockApplication.getGroup()).thenReturn(mockGroup); when(mockApplication.getWebAppContext()).thenReturn("/test-app-context"); when(mockApplication.isLoadBalanceAcrossServers()).thenReturn(true); when(mockApplication.isSecure()).thenReturn(true); when(mockAppPersistence.getApplication(anyString())).thenReturn(mockApplication); groupAppResourceHandler.updateResourceMetaData(resourceIdentifier, resourceName, updatedMetaData); }
@Override public String updateResourceMetaData(final ResourceIdentifier resourceIdentifier, final String resourceName, final String metaData) { if (canHandle(resourceIdentifier)) { final String previousMetaData = groupPersistenceService.getGroupAppResourceTemplateMetaData(resourceIdentifier.groupName, resourceName, resourceIdentifier.webAppName); final String updatedMetaData = groupPersistenceService.updateGroupAppResourceMetaData(resourceIdentifier.groupName, resourceIdentifier.webAppName, resourceName, metaData); updateApplicationUnpackWar(resourceIdentifier.webAppName, resourceName, metaData); updateMetaDataForChildJVMResources(resourceIdentifier, resourceName, metaData); updateAppTemplatesWhenDeployToJvmsChanged(resourceIdentifier, resourceName, previousMetaData, updatedMetaData); return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } }
GroupLevelAppResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(final ResourceIdentifier resourceIdentifier, final String resourceName, final String metaData) { if (canHandle(resourceIdentifier)) { final String previousMetaData = groupPersistenceService.getGroupAppResourceTemplateMetaData(resourceIdentifier.groupName, resourceName, resourceIdentifier.webAppName); final String updatedMetaData = groupPersistenceService.updateGroupAppResourceMetaData(resourceIdentifier.groupName, resourceIdentifier.webAppName, resourceName, metaData); updateApplicationUnpackWar(resourceIdentifier.webAppName, resourceName, metaData); updateMetaDataForChildJVMResources(resourceIdentifier, resourceName, metaData); updateAppTemplatesWhenDeployToJvmsChanged(resourceIdentifier, resourceName, previousMetaData, updatedMetaData); return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } }
GroupLevelAppResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(final ResourceIdentifier resourceIdentifier, final String resourceName, final String metaData) { if (canHandle(resourceIdentifier)) { final String previousMetaData = groupPersistenceService.getGroupAppResourceTemplateMetaData(resourceIdentifier.groupName, resourceName, resourceIdentifier.webAppName); final String updatedMetaData = groupPersistenceService.updateGroupAppResourceMetaData(resourceIdentifier.groupName, resourceIdentifier.webAppName, resourceName, metaData); updateApplicationUnpackWar(resourceIdentifier.webAppName, resourceName, metaData); updateMetaDataForChildJVMResources(resourceIdentifier, resourceName, metaData); updateAppTemplatesWhenDeployToJvmsChanged(resourceIdentifier, resourceName, previousMetaData, updatedMetaData); return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } GroupLevelAppResourceHandler(final ResourceDao resourceDao,
                                        final GroupPersistenceService groupPersistenceService,
                                        final JvmPersistenceService jvmPersistenceService,
                                        final ApplicationPersistenceService applicationPersistenceService,
                                        final ResourceHandler successor); }
GroupLevelAppResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(final ResourceIdentifier resourceIdentifier, final String resourceName, final String metaData) { if (canHandle(resourceIdentifier)) { final String previousMetaData = groupPersistenceService.getGroupAppResourceTemplateMetaData(resourceIdentifier.groupName, resourceName, resourceIdentifier.webAppName); final String updatedMetaData = groupPersistenceService.updateGroupAppResourceMetaData(resourceIdentifier.groupName, resourceIdentifier.webAppName, resourceName, metaData); updateApplicationUnpackWar(resourceIdentifier.webAppName, resourceName, metaData); updateMetaDataForChildJVMResources(resourceIdentifier, resourceName, metaData); updateAppTemplatesWhenDeployToJvmsChanged(resourceIdentifier, resourceName, previousMetaData, updatedMetaData); return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } GroupLevelAppResourceHandler(final ResourceDao resourceDao,
                                        final GroupPersistenceService groupPersistenceService,
                                        final JvmPersistenceService jvmPersistenceService,
                                        final ApplicationPersistenceService applicationPersistenceService,
                                        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(final ResourceIdentifier resourceIdentifier, final String resourceName, final String metaData); @Override Object getSelectedValue(ResourceIdentifier resourceIdentifier); @Override List<String> getResourceNames(ResourceIdentifier resourceIdentifier); }
GroupLevelAppResourceHandler extends ResourceHandler { @Override public String updateResourceMetaData(final ResourceIdentifier resourceIdentifier, final String resourceName, final String metaData) { if (canHandle(resourceIdentifier)) { final String previousMetaData = groupPersistenceService.getGroupAppResourceTemplateMetaData(resourceIdentifier.groupName, resourceName, resourceIdentifier.webAppName); final String updatedMetaData = groupPersistenceService.updateGroupAppResourceMetaData(resourceIdentifier.groupName, resourceIdentifier.webAppName, resourceName, metaData); updateApplicationUnpackWar(resourceIdentifier.webAppName, resourceName, metaData); updateMetaDataForChildJVMResources(resourceIdentifier, resourceName, metaData); updateAppTemplatesWhenDeployToJvmsChanged(resourceIdentifier, resourceName, previousMetaData, updatedMetaData); return updatedMetaData; } else { return successor.updateResourceMetaData(resourceIdentifier, resourceName, metaData); } } GroupLevelAppResourceHandler(final ResourceDao resourceDao,
                                        final GroupPersistenceService groupPersistenceService,
                                        final JvmPersistenceService jvmPersistenceService,
                                        final ApplicationPersistenceService applicationPersistenceService,
                                        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(final ResourceIdentifier resourceIdentifier, final String resourceName, final String metaData); @Override Object getSelectedValue(ResourceIdentifier resourceIdentifier); @Override List<String> getResourceNames(ResourceIdentifier resourceIdentifier);  }