org.camunda.bpm.engine.RepositoryService.updateDecisionDefinitionHistoryTimeToLive()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(13.5k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.camunda.bpm.engine.RepositoryService.updateDecisionDefinitionHistoryTimeToLive方法的一些代码示例,展示了RepositoryService.updateDecisionDefinitionHistoryTimeToLive的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryService.updateDecisionDefinitionHistoryTimeToLive方法的具体详情如下:
包路径:org.camunda.bpm.engine.RepositoryService
类名称:RepositoryService
方法名:updateDecisionDefinitionHistoryTimeToLive

RepositoryService.updateDecisionDefinitionHistoryTimeToLive介绍

[英]Updates time to live of decision definition. The field is used within history cleanup process.
[中]更新决策定义的生存时间。该字段在历史清理过程中使用。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public void updateHistoryTimeToLive(HistoryTimeToLiveDto historyTimeToLiveDto) {
 engine.getRepositoryService().updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, historyTimeToLiveDto.getHistoryTimeToLive());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public void updateHistoryTimeToLive(HistoryTimeToLiveDto historyTimeToLiveDto) {
 engine.getRepositoryService().updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, historyTimeToLiveDto.getHistoryTimeToLive());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void updateHistoryTimeToLiveWithAuthenticatedTenant() {
 identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, 6);
 DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
 assertThat(definition.getTenantId(), is(TENANT_ONE));
 assertThat(definition.getHistoryTimeToLive(), is(6));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testUpdateHistoryTimeToLiveNegativeValue() {
 String expectedMessage = "expectedMessage";
 doThrow(new BadUserRequestException(expectedMessage))
   .when(repositoryServiceMock)
   .updateDecisionDefinitionHistoryTimeToLive(eq(MockProvider.EXAMPLE_DECISION_DEFINITION_ID), eq(-1));
 given()
   .pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID)
   .content(new HistoryTimeToLiveDto(-1))
   .contentType(ContentType.JSON)
   .then().expect()
   .statusCode(Status.BAD_REQUEST.getStatusCode())
   .body("type", is(BadUserRequestException.class.getSimpleName()))
   .body("message", containsString(expectedMessage))
   .when()
   .put(UPDATE_HISTORY_TIME_TO_LIVE_URL);
 verify(repositoryServiceMock).updateDecisionDefinitionHistoryTimeToLive(MockProvider.EXAMPLE_DECISION_DEFINITION_ID, -1);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testUpdateHistoryTimeToLiveAuthorizationException() {
 String expectedMessage = "expectedMessage";
 doThrow(new AuthorizationException(expectedMessage))
   .when(repositoryServiceMock)
   .updateDecisionDefinitionHistoryTimeToLive(eq(MockProvider.EXAMPLE_DECISION_DEFINITION_ID), eq(5));
 given()
   .pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID)
   .content(new HistoryTimeToLiveDto(5))
   .contentType(ContentType.JSON)
   .then().expect()
   .statusCode(Status.FORBIDDEN.getStatusCode())
   .body("type", is(AuthorizationException.class.getSimpleName()))
   .body("message", containsString(expectedMessage))
   .when()
   .put(UPDATE_HISTORY_TIME_TO_LIVE_URL);
 verify(repositoryServiceMock).updateDecisionDefinitionHistoryTimeToLive(MockProvider.EXAMPLE_DECISION_DEFINITION_ID, 5);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void updateHistoryTimeToLiveNoAuthenticatedTenants() {
 identityService.setAuthentication("user", null, null);
 // declare expected exception
 thrown.expect(ProcessEngineException.class);
 thrown.expectMessage("Cannot update the decision definition");
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, 6);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testDecisionDefinitionUpdateTimeToLive() {
 //given
 String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
 createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, UPDATE);
 //when
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, 6);
 //then
 assertEquals(6, selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getHistoryTimeToLive().intValue());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = { "org/camunda/bpm/engine/test/api/dmn/Example.dmn"})
public void testDecisionDefinitionUpdateTimeToLive() {
 //given
 DecisionDefinition decisionDefinition = findOnlyDecisionDefinition();
 //when
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), 6);
 //then
 decisionDefinition = findOnlyDecisionDefinition();
 assertEquals(6, decisionDefinition.getHistoryTimeToLive().intValue());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = { "org/camunda/bpm/engine/test/api/dmn/Example.dmn"})
public void testDecisionDefinitionUpdateTimeToLiveNegative() {
 //given
 DecisionDefinition decisionDefinition = findOnlyDecisionDefinition();
 //when
 try {
  repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), -1);
  fail("Exception is expected, that negative value is not allowed.");
 } catch (BadUserRequestException ex) {
  assertTrue(ex.getMessage().contains("greater than"));
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
@Deployment(resources = {
 "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml"
})
public void shouldResolveStandaloneHistoricDecisionInstance() {
 // given
 ClockUtil.setCurrentTime(START_DATE);
 DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery()
  .decisionDefinitionKey("dish-decision")
  .singleResult();
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), 5);
 // when
 decisionService.evaluateDecisionTableByKey("dish-decision", Variables.createVariables()
  .putValue("temperature", 32)
  .putValue("dayType", "Weekend"));
 List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
 // assume
 assertThat(historicDecisionInstances.size(), is(3));
 Date removalTime = addDays(START_DATE, 5);
 // then
 assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime));
 assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime));
 assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void updateHistoryTimeToLiveDisabledTenantCheck() {
 processEngineConfiguration.setTenantCheckEnabled(false);
 identityService.setAuthentication("user", null, null);
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, 6);
 DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
 assertThat(definition.getTenantId(), is(TENANT_ONE));
 assertThat(definition.getHistoryTimeToLive(), is(6));
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void removeHistoryTimeToLive() {
 List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey(ONE_TASK_PROCESS).list();
 assertEquals(1, processDefinitions.size());
 repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinitions.get(0).getId(), null);
 final List<DecisionDefinition> decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION).list();
 assertEquals(1, decisionDefinitions.size());
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), null);
 final List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(ONE_TASK_CASE).list();
 assertEquals(1, caseDefinitions.size());
 repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitions.get(0).getId(), null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testUpdateHistoryTimeToLiveNullValue() {
 given()
   .pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID)
   .content(new HistoryTimeToLiveDto())
   .contentType(ContentType.JSON)
   .then().expect()
   .statusCode(Status.NO_CONTENT.getStatusCode())
   .when()
   .put(UPDATE_HISTORY_TIME_TO_LIVE_URL);
 verify(repositoryServiceMock).updateDecisionDefinitionHistoryTimeToLive(MockProvider.EXAMPLE_DECISION_DEFINITION_ID, null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testUpdateHistoryTimeToLive() {
 given()
   .pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID)
   .content(new HistoryTimeToLiveDto(5))
   .contentType(ContentType.JSON)
   .then().expect()
   .statusCode(Status.NO_CONTENT.getStatusCode())
   .when()
   .put(UPDATE_HISTORY_TIME_TO_LIVE_URL);
 verify(repositoryServiceMock).updateDecisionDefinitionHistoryTimeToLive(MockProvider.EXAMPLE_DECISION_DEFINITION_ID, 5);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = { "org/camunda/bpm/engine/test/api/dmn/Example.dmn"})
public void testDecisionDefinitionUpdateTimeToLiveNull() {
 //given
 DecisionDefinition decisionDefinition = findOnlyDecisionDefinition();
 //when
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), null);
 //then
 decisionDefinition = (DecisionDefinitionEntity) repositoryService.getDecisionDefinition(decisionDefinition.getId());
 assertEquals(null, decisionDefinition.getHistoryTimeToLive());
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void prepareHistoricDecisions(int instanceCount) {
  Date oldCurrentTime = ClockUtil.getCurrentTime();
  List<DecisionDefinition> decisionDefinitions = engineRule.getRepositoryService().createDecisionDefinitionQuery().decisionDefinitionKey("decision").list();
  assertEquals(1, decisionDefinitions.size());
  engineRule.getRepositoryService().updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), 5);

  ClockUtil.setCurrentTime(DateUtils.addDays(new Date(), -6));
  for (int i = 0; i < instanceCount; i++) {
   engineRule.getDecisionService().evaluateDecisionByKey("decision").variables(Variables.createVariables().putValue("status", "silver").putValue("sum", 723))
     .evaluate();
  }
  ClockUtil.setCurrentTime(oldCurrentTime);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void prepareDecisionInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount) {
 List<DecisionDefinition> decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).list();
 assertEquals(1, decisionDefinitions.size());
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), historyTimeToLive);
 Date oldCurrentTime = ClockUtil.getCurrentTime();
 ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, daysInThePast));
 Map<String, Object> variables = Variables.createVariables().putValue("status", "silver").putValue("sum", 723);
 for (int i = 0; i < instanceCount; i++) {
  engineRule.getDecisionService().evaluateDecisionByKey(key).variables(variables).evaluate();
 }
 ClockUtil.setCurrentTime(oldCurrentTime);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testDecisionDefinitionUpdateTimeToLiveWithoutAuthorizations() {
 //given
 String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
 try {
  //when
  repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, 6);
  fail("Exception expected");
 } catch (AuthorizationException e) {
  // then
  String message = e.getMessage();
  assertTextPresent(userId, message);
  assertTextPresent(UPDATE.getName(), message);
  assertTextPresent(DECISION_DEFINITION_KEY, message);
  assertTextPresent(DECISION_DEFINITION.resourceName(), message);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void prepareDecisionInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount) {
 DecisionDefinition decisionDefinition = selectDecisionDefinitionByKey(key);
 disableAuthorization();
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), historyTimeToLive);
 enableAuthorization();
 Date oldCurrentTime = ClockUtil.getCurrentTime();
 ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, daysInThePast));
 Map<String, Object> variables = Variables.createVariables().putValue("input1", null);
 for (int i = 0; i < instanceCount; i++) {
  disableAuthorization();
  decisionService.evaluateDecisionByKey(key).variables(variables).evaluate();
  enableAuthorization();
 }
 ClockUtil.setCurrentTime(oldCurrentTime);
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void prepareDecisionInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount, String tenantId) {
 List<DecisionDefinition> decisionDefinitions = null;
 if (tenantId != null) {
  decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).tenantIdIn(tenantId).list();
 } else {
  decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).withoutTenantId().list();
 }
 assertEquals(1, decisionDefinitions.size());
 repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), historyTimeToLive);
 Date oldCurrentTime = ClockUtil.getCurrentTime();
 ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, daysInThePast));
 Map<String, Object> variables = Variables.createVariables().putValue("status", "silver").putValue("sum", 723);
 for (int i = 0; i < instanceCount; i++) {
  if (tenantId != null) {
   engineRule.getDecisionService().evaluateDecisionByKey(key).decisionDefinitionTenantId(tenantId).variables(variables).evaluate();
  } else {
   engineRule.getDecisionService().evaluateDecisionByKey(key).decisionDefinitionWithoutTenantId().variables(variables).evaluate();
  }
 }
 ClockUtil.setCurrentTime(oldCurrentTime);
}

相关文章

微信公众号

最新文章

更多

RepositoryService类方法