예제 #1
0
  @Test
  public void rescheduleErroneousTriggers_should_call_rescheduleErroneousTriggers()
      throws Exception {
    platformAPI.rescheduleErroneousTriggers();

    verify(schedulerService).rescheduleErroneousTriggers();
  }
예제 #2
0
  @Test
  public void registerMissingTenantsDefaultJobs_should_not_call_registerJob_when_job_is_scheduled()
      throws BonitaHomeNotSetException, BonitaHomeConfigurationException, NoSuchMethodException,
          InstantiationException, IllegalAccessException, InvocationTargetException,
          SBonitaException, IOException, ClassNotFoundException {
    // Given
    final TransactionService transactionService = mock(TransactionService.class);
    doReturn(transactionService).when(platformServiceAccessor).getTransactionService();
    doNothing().when(transactionService).begin();
    doNothing().when(transactionService).complete();
    final JobRegister jobRegister = mock(JobRegister.class);
    doReturn("existingJob").when(jobRegister).getJobName();
    final List<JobRegister> defaultJobs = Collections.singletonList(jobRegister);
    doReturn(defaultJobs).when(tenantConfiguration).getJobsToRegister();
    final List<String> scheduledJobNames = Collections.singletonList("existingJob");
    doReturn(scheduledJobNames).when(schedulerService).getJobs();
    doNothing().when(platformAPI).registerJob(schedulerService, jobRegister);

    // When
    platformAPI.registerMissingTenantsDefaultJobs(
        platformServiceAccessor, sessionAccessor, tenants);

    // Then
    verify(platformAPI, never()).registerJob(schedulerService, jobRegister);
  }
예제 #3
0
  @Test
  public void startNode_should_call_startScheduler_when_node_is_not_started() throws Exception {
    // Given
    doNothing().when(platformAPI).checkPlatformVersion(platformServiceAccessor);
    doNothing().when(platformAPI).startPlatformServices(platformServiceAccessor);
    doReturn(false).when(platformAPI).isNodeStarted();
    doNothing()
        .when(platformAPI)
        .beforeServicesStartOfRestartHandlersOfTenant(
            platformServiceAccessor, sessionAccessor, tenants);
    doNothing()
        .when(platformAPI)
        .startServicesOfTenants(platformServiceAccessor, sessionAccessor, tenants);
    doNothing().when(platformAPI).restartHandlersOfPlatform(platformServiceAccessor);
    doNothing()
        .when(platformAPI)
        .afterServicesStartOfRestartHandlersOfTenant(
            platformServiceAccessor, sessionAccessor, tenants);
    doNothing()
        .when(platformAPI)
        .registerMissingTenantsDefaultJobs(platformServiceAccessor, sessionAccessor, tenants);

    // When
    platformAPI.startNode();

    // Then
    verify(platformAPI).startScheduler(platformServiceAccessor, tenants);
  }
예제 #4
0
  @Test(expected = UpdateException.class)
  public void rescheduleErroneousTriggers_should_throw_exception_when_cant_getPlatformAccessor()
      throws Exception {
    doThrow(new IOException()).when(platformAPI).getPlatformAccessor();

    platformAPI.rescheduleErroneousTriggers();
  }
예제 #5
0
  @Test(expected = UpdateException.class)
  public void
      rescheduleErroneousTriggers_should_throw_exception_when_rescheduleErroneousTriggers_failed()
          throws Exception {
    doThrow(new SSchedulerException("failed")).when(schedulerService).rescheduleErroneousTriggers();

    platformAPI.rescheduleErroneousTriggers();
  }
예제 #6
0
  @Test
  public void
      startScheduler_should_register_PlatformJobListeners_and_TenantJobListeners_when_scheduler_starts()
          throws Exception {
    // Given
    doReturn(true).when(platformConfiguration).shouldStartScheduler();
    doReturn(false).when(schedulerService).isStarted();

    // When
    platformAPI.startScheduler(platformServiceAccessor, tenants);

    // Then
    verify(schedulerService).initializeScheduler();
    verify(schedulerService).addJobListener(anyListOf(AbstractBonitaPlatformJobListener.class));
    verify(schedulerService)
        .addJobListener(anyListOf(AbstractBonitaTenantJobListener.class), anyString());
    verify(schedulerService).start();
  }
예제 #7
0
  @Test
  public void startScheduler_should_not_register_JobListeners_when_none_are_configured()
      throws Exception {
    // Given
    doReturn(true).when(platformConfiguration).shouldStartScheduler();
    doReturn(false).when(schedulerService).isStarted();
    doReturn(Collections.EMPTY_LIST).when(platformConfiguration).getJobListeners();
    doReturn(Collections.EMPTY_LIST).when(tenantConfiguration).getJobListeners();

    // When
    platformAPI.startScheduler(platformServiceAccessor, tenants);

    // Then
    verify(schedulerService).initializeScheduler();
    verify(schedulerService, never())
        .addJobListener(anyListOf(AbstractBonitaPlatformJobListener.class));
    verify(schedulerService, never())
        .addJobListener(anyListOf(AbstractBonitaTenantJobListener.class), anyString());
    verify(schedulerService).start();
  }
예제 #8
0
  @Test
  public void startNode_should_call_registerMissingTenantsDefaultJobs() throws Exception {
    // Given
    doNothing().when(platformAPI).checkPlatformVersion(platformServiceAccessor);
    doNothing().when(platformAPI).startPlatformServices(platformServiceAccessor);
    doReturn(true).when(platformAPI).isNodeStarted();
    doNothing()
        .when(platformAPI)
        .startServicesOfTenants(platformServiceAccessor, sessionAccessor, tenants);
    doNothing()
        .when(platformAPI)
        .registerMissingTenantsDefaultJobs(platformServiceAccessor, sessionAccessor, tenants);

    // When
    platformAPI.startNode();

    // Then
    verify(platformAPI)
        .registerMissingTenantsDefaultJobs(platformServiceAccessor, sessionAccessor, tenants);
  }