@Test
  public void testQueryAuthenticatedTenant() {
    DecisionRequirementsDefinition decisionRequirementsDefinition =
        repositoryService
            .createDecisionRequirementsDefinitionQuery()
            .tenantIdIn(TENANT_ONE)
            .singleResult();

    identityService.setAuthentication(USER_ID, null, Arrays.asList(TENANT_ONE));

    HistoricDecisionInstanceStatisticsQuery query =
        historyService.createHistoricDecisionInstanceStatisticsQuery(
            decisionRequirementsDefinition.getId());

    assertThat(query.count(), is(3L));
  }
  @Test
  public void testQueryDisabledTenantCheck() {
    DecisionRequirementsDefinition decisionRequirementsDefinition =
        repositoryService
            .createDecisionRequirementsDefinitionQuery()
            .tenantIdIn(TENANT_ONE)
            .singleResult();

    engineRule.getProcessEngineConfiguration().setTenantCheckEnabled(false);
    identityService.setAuthentication(USER_ID, null, null);

    HistoricDecisionInstanceStatisticsQuery query =
        historyService.createHistoricDecisionInstanceStatisticsQuery(
            decisionRequirementsDefinition.getId());

    assertThat(query.count(), is(3L));
  }
  public InputStream execute(final CommandContext commandContext) {
    DecisionRequirementsDefinition decisionRequirementsDefinition =
        new GetDeploymentDecisionRequirementsDefinitionCmd(decisionRequirementsDefinitionId)
            .execute(commandContext);

    final String deploymentId = decisionRequirementsDefinition.getDeploymentId();
    final String resourceName = decisionRequirementsDefinition.getDiagramResourceName();

    if (resourceName != null) {
      return commandContext.runWithoutAuthorization(
          new Callable<InputStream>() {
            public InputStream call() throws Exception {
              return new GetDeploymentResourceCmd(deploymentId, resourceName)
                  .execute(commandContext);
            }
          });
    } else {
      return null;
    }
  }