@Test public void testUploadTemplate() { final UploadAppTemplateRequest cmd = mock(UploadAppTemplateRequest.class); when(cmd.getConfFileName()).thenReturn("roleMapping.properties"); when(cmd.getJvmName()).thenReturn("testJvmName"); Jvm mockJvm = mock(Jvm.class); when(mockJvm.getId()).thenReturn(new Identifier<Jvm>(111L)); when(Config.jvmPersistenceService.findJvmByExactName(anyString())).thenReturn(mockJvm); JpaJvm mockJpaJvm = mock(JpaJvm.class); when(Config.jvmPersistenceService.getJpaJvm(any(Identifier.class), anyBoolean())).thenReturn(mockJpaJvm); applicationService.uploadAppTemplate(cmd); verify(cmd).validate(); verify(Config.applicationPersistenceService).uploadAppTemplate(any(UploadAppTemplateRequest.class), any(JpaJvm.class)); List<Jvm> jvmList = new ArrayList<>(); jvmList.add(mockJvm); when(mockJvm.getJvmName()).thenReturn("testJvmName"); when(cmd.getConfFileName()).thenReturn("hct.xml"); applicationService.uploadAppTemplate(cmd); verify(cmd, times(2)).validate(); verify(Config.applicationPersistenceService, times(2)).uploadAppTemplate(any(UploadAppTemplateRequest.class), any(JpaJvm.class)); when(mockJvm.getJvmName()).thenReturn("notTestJvmName"); applicationService.uploadAppTemplate(cmd); verify(cmd, times(3)).validate(); verify(Config.applicationPersistenceService, times(3)).uploadAppTemplate(any(UploadAppTemplateRequest.class), any(JpaJvm.class)); }
@Override @Transactional public JpaApplicationConfigTemplate uploadAppTemplate(UploadAppTemplateRequest uploadAppTemplateRequest) { uploadAppTemplateRequest.validate(); Jvm jvm = jvmPersistenceService.findJvmByExactName(uploadAppTemplateRequest.getJvmName()); JpaJvm jpaJvm = jvmPersistenceService.getJpaJvm(jvm.getId(), false); return applicationPersistenceService.uploadAppTemplate(uploadAppTemplateRequest, jpaJvm); }
ApplicationServiceImpl implements ApplicationService { @Override @Transactional public JpaApplicationConfigTemplate uploadAppTemplate(UploadAppTemplateRequest uploadAppTemplateRequest) { uploadAppTemplateRequest.validate(); Jvm jvm = jvmPersistenceService.findJvmByExactName(uploadAppTemplateRequest.getJvmName()); JpaJvm jpaJvm = jvmPersistenceService.getJpaJvm(jvm.getId(), false); return applicationPersistenceService.uploadAppTemplate(uploadAppTemplateRequest, jpaJvm); } }
ApplicationServiceImpl implements ApplicationService { @Override @Transactional public JpaApplicationConfigTemplate uploadAppTemplate(UploadAppTemplateRequest uploadAppTemplateRequest) { uploadAppTemplateRequest.validate(); Jvm jvm = jvmPersistenceService.findJvmByExactName(uploadAppTemplateRequest.getJvmName()); JpaJvm jpaJvm = jvmPersistenceService.getJpaJvm(jvm.getId(), false); return applicationPersistenceService.uploadAppTemplate(uploadAppTemplateRequest, jpaJvm); } ApplicationServiceImpl(final ApplicationPersistenceService applicationPersistenceService,
                                  final JvmPersistenceService jvmPersistenceService,
                                  final GroupPersistenceService groupPersistenceService,
                                  final ResourceService resourceService,
                                  final BinaryDistributionService binaryDistributionService,
                                  final HistoryFacadeService historyFacadeService,
                                  final BinaryDistributionLockManager binaryDistributionLockManager); }
ApplicationServiceImpl implements ApplicationService { @Override @Transactional public JpaApplicationConfigTemplate uploadAppTemplate(UploadAppTemplateRequest uploadAppTemplateRequest) { uploadAppTemplateRequest.validate(); Jvm jvm = jvmPersistenceService.findJvmByExactName(uploadAppTemplateRequest.getJvmName()); JpaJvm jpaJvm = jvmPersistenceService.getJpaJvm(jvm.getId(), false); return applicationPersistenceService.uploadAppTemplate(uploadAppTemplateRequest, jpaJvm); } ApplicationServiceImpl(final ApplicationPersistenceService applicationPersistenceService,
                                  final JvmPersistenceService jvmPersistenceService,
                                  final GroupPersistenceService groupPersistenceService,
                                  final ResourceService resourceService,
                                  final BinaryDistributionService binaryDistributionService,
                                  final HistoryFacadeService historyFacadeService,
                                  final BinaryDistributionLockManager binaryDistributionLockManager); @Transactional(readOnly = true) @Override Application getApplication(Identifier<Application> aApplicationId); @Transactional(readOnly = true) @Override Application getApplication(final String name); @Transactional(readOnly = true) @Override List<Application> getApplications(); @Transactional(readOnly = true) @Override List<Application> findApplications(Identifier<Group> groupId); @Transactional(readOnly = true) @Override List<Application> findApplicationsByJvmId(Identifier<Jvm> jvmId); @Transactional @Override Application updateApplication(UpdateApplicationRequest updateApplicationRequest, User anUpdatingUser); @Transactional @Override Application createApplication(final CreateApplicationRequest createApplicationRequest,
                                         final User aCreatingUser); @Transactional @Override void removeApplication(Identifier<Application> anAppIdToRemove, User user); @Override @Transactional(readOnly = true) List<String> getResourceTemplateNames(final String appName, final String jvmName); @Override @Transactional String updateResourceTemplate(final String appName, final String resourceTemplateName, final String template, final String jvmName, final String groupName); @Override @Transactional // TODO: Have an option to do a hot deploy or not. CommandOutput deployConf(final String appName, final String groupName, final String jvmName,
                                    final String resourceTemplateName, ResourceGroup resourceGroup, User user); @Override @Transactional JpaApplicationConfigTemplate uploadAppTemplate(UploadAppTemplateRequest uploadAppTemplateRequest); @Override @Transactional String previewResourceTemplate(String fileName, String appName, String groupName, String jvmName, String template, ResourceGroup resourceGroup); @Override @Transactional void copyApplicationWarToGroupHosts(Application application); @Override void deployApplicationResourcesToGroupHosts(String groupName, Application app, ResourceGroup resourceGroup); @Override @Transactional void copyApplicationWarToHost(Application application, String hostName); @Override void deployConf(final String appName, final String hostName, final User user); }
ApplicationServiceImpl implements ApplicationService { @Override @Transactional public JpaApplicationConfigTemplate uploadAppTemplate(UploadAppTemplateRequest uploadAppTemplateRequest) { uploadAppTemplateRequest.validate(); Jvm jvm = jvmPersistenceService.findJvmByExactName(uploadAppTemplateRequest.getJvmName()); JpaJvm jpaJvm = jvmPersistenceService.getJpaJvm(jvm.getId(), false); return applicationPersistenceService.uploadAppTemplate(uploadAppTemplateRequest, jpaJvm); } ApplicationServiceImpl(final ApplicationPersistenceService applicationPersistenceService,
                                  final JvmPersistenceService jvmPersistenceService,
                                  final GroupPersistenceService groupPersistenceService,
                                  final ResourceService resourceService,
                                  final BinaryDistributionService binaryDistributionService,
                                  final HistoryFacadeService historyFacadeService,
                                  final BinaryDistributionLockManager binaryDistributionLockManager); @Transactional(readOnly = true) @Override Application getApplication(Identifier<Application> aApplicationId); @Transactional(readOnly = true) @Override Application getApplication(final String name); @Transactional(readOnly = true) @Override List<Application> getApplications(); @Transactional(readOnly = true) @Override List<Application> findApplications(Identifier<Group> groupId); @Transactional(readOnly = true) @Override List<Application> findApplicationsByJvmId(Identifier<Jvm> jvmId); @Transactional @Override Application updateApplication(UpdateApplicationRequest updateApplicationRequest, User anUpdatingUser); @Transactional @Override Application createApplication(final CreateApplicationRequest createApplicationRequest,
                                         final User aCreatingUser); @Transactional @Override void removeApplication(Identifier<Application> anAppIdToRemove, User user); @Override @Transactional(readOnly = true) List<String> getResourceTemplateNames(final String appName, final String jvmName); @Override @Transactional String updateResourceTemplate(final String appName, final String resourceTemplateName, final String template, final String jvmName, final String groupName); @Override @Transactional // TODO: Have an option to do a hot deploy or not. CommandOutput deployConf(final String appName, final String groupName, final String jvmName,
                                    final String resourceTemplateName, ResourceGroup resourceGroup, User user); @Override @Transactional JpaApplicationConfigTemplate uploadAppTemplate(UploadAppTemplateRequest uploadAppTemplateRequest); @Override @Transactional String previewResourceTemplate(String fileName, String appName, String groupName, String jvmName, String template, ResourceGroup resourceGroup); @Override @Transactional void copyApplicationWarToGroupHosts(Application application); @Override void deployApplicationResourcesToGroupHosts(String groupName, Application app, ResourceGroup resourceGroup); @Override @Transactional void copyApplicationWarToHost(Application application, String hostName); @Override void deployConf(final String appName, final String hostName, final User user);  }