本文整理了Java中org.camunda.bpm.engine.TaskService.getVariableLocalTyped()
方法的一些代码示例,展示了TaskService.getVariableLocalTyped()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TaskService.getVariableLocalTyped()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.TaskService
类名称:TaskService
方法名:getVariableLocalTyped
[英]Get a variables and only search in the task scope.
[中]获取变量并仅在任务范围内搜索。
代码示例来源:origin: camunda/camunda-bpm-platform
protected TypedValue getVariableEntity(String variableKey, boolean deserializeValue) {
return engine.getTaskService().getVariableLocalTyped(resourceId, variableKey, deserializeValue);
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected TypedValue getVariableEntity(String variableKey, boolean deserializeValue) {
return engine.getTaskService().getVariableLocalTyped(resourceId, variableKey, deserializeValue);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetSingleLocalVariabledataNotBinary() {
when(taskServiceMock.getVariableLocalTyped(anyString(), eq(EXAMPLE_VARIABLE_KEY), eq(false))).thenReturn(EXAMPLE_VARIABLE_VALUE);
given()
.pathParam("id", MockProvider.EXAMPLE_TASK_ID)
.pathParam("varId", EXAMPLE_VARIABLE_KEY)
.then()
.expect()
.statusCode(Status.BAD_REQUEST.getStatusCode())
.when()
.get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
verify(taskServiceMock).getVariableLocalTyped(MockProvider.EXAMPLE_TASK_ID, EXAMPLE_VARIABLE_KEY, false);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetSingleLocalVariableData() {
when(taskServiceMock.getVariableLocalTyped(anyString(), eq(EXAMPLE_BYTES_VARIABLE_KEY), eq(false))).thenReturn(EXAMPLE_VARIABLE_VALUE_BYTES);
given()
.pathParam("id", MockProvider.EXAMPLE_TASK_ID)
.pathParam("varId", EXAMPLE_BYTES_VARIABLE_KEY)
.then()
.expect()
.statusCode(Status.OK.getStatusCode())
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.when()
.get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
verify(taskServiceMock).getVariableLocalTyped(MockProvider.EXAMPLE_TASK_ID, EXAMPLE_BYTES_VARIABLE_KEY, false);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetSingleLocalVariableDataNonExisting() {
when(taskServiceMock.getVariableLocalTyped(anyString(), eq("nonExisting"), eq(false))).thenReturn(null);
given()
.pathParam("id", MockProvider.EXAMPLE_TASK_ID)
.pathParam("varId", "nonExisting")
.then()
.expect()
.statusCode(Status.NOT_FOUND.getStatusCode())
.body("type", is(InvalidRequestException.class.getSimpleName()))
.body("message", is("task variable with name " + "nonExisting" + " does not exist"))
.when()
.get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
verify(taskServiceMock).getVariableLocalTyped(MockProvider.EXAMPLE_TASK_ID, "nonExisting", false);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@SuppressWarnings("unchecked")
public <T extends TypedValue> T getVariableLocal(String variableName) {
TypedValue value = cachedVariablesLocal.getValueTyped(variableName);
if (value == null) {
if (task != null) {
value = taskService.getVariableLocalTyped(task.getId(), variableName);
cachedVariablesLocal.put(variableName, value);
} else if (execution != null) {
value = runtimeService.getVariableLocalTyped(execution.getId(), variableName);
cachedVariablesLocal.put(variableName, value);
}
}
return (T) value;
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetLocalVariableForNonExistingTaskId() {
String variableKey = "aVariableKey";
when(taskServiceMock.getVariableLocalTyped(eq(NON_EXISTING_ID), eq(variableKey), anyBoolean()))
.thenThrow(new ProcessEngineException("task " + NON_EXISTING_ID + " doesn't exist"));
given().pathParam("id", NON_EXISTING_ID).pathParam("varId", variableKey)
.header("accept", MediaType.APPLICATION_JSON)
.then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode())
.body("type", is(RestException.class.getSimpleName()))
.body("message", is("Cannot get task variable " + variableKey + ": task " + NON_EXISTING_ID + " doesn't exist"))
.when().get(SINGLE_TASK_SINGLE_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testCannotDownloadVariableOtherThanFile() {
String variableKey = "aVariableKey";
BooleanValue variableValue = Variables.booleanValue(true);
when(taskServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
given()
.pathParam("id", EXAMPLE_TASK_ID)
.pathParam("varId", variableKey)
.then().expect()
.statusCode(Status.BAD_REQUEST.getStatusCode())
.when().get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetSingleLocalVariableThrowsAuthorizationException() {
String variableKey = "aVariableKey";
String message = "excpected exception";
when(taskServiceMock.getVariableLocalTyped(anyString(), anyString(), anyBoolean())).thenThrow(new AuthorizationException(message));
given()
.pathParam("id", EXAMPLE_TASK_ID)
.pathParam("varId", variableKey)
.then().expect()
.statusCode(Status.FORBIDDEN.getStatusCode())
.body("type", is(AuthorizationException.class.getSimpleName()))
.body("message", is(message))
.when()
.get(SINGLE_TASK_SINGLE_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetSingleLocalVariable() {
String variableKey = "aVariableKey";
int variableValue = 123;
when(taskServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean()))
.thenReturn(Variables.integerValue(variableValue));
given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey)
.header("accept", MediaType.APPLICATION_JSON)
.then().expect().statusCode(Status.OK.getStatusCode())
.body("value", is(123))
.body("type", is("Integer"))
.when().get(SINGLE_TASK_SINGLE_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetFileVariableDownloadWithTypeAndEncoding() {
String variableKey = "aVariableKey";
final byte[] byteContent = "some bytes".getBytes();
String filename = "test.txt";
String encoding = "UTF-8";
FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create();
when(taskServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
Response response = given()
.pathParam("id", EXAMPLE_TASK_ID)
.pathParam("varId", variableKey)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.body(is(equalTo(new String(byteContent))))
.when().get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
String contentType = response.contentType().replaceAll(" ", "");
assertThat(contentType, is(ContentType.TEXT + ";charset=" + encoding));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetFileVariableDownloadWithType() {
String variableKey = "aVariableKey";
final byte[] byteContent = "some bytes".getBytes();
String filename = "test.txt";
FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).create();
when(taskServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);
given()
.pathParam("id", EXAMPLE_TASK_ID)
.pathParam("varId", variableKey)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.contentType(ContentType.TEXT.toString())
.and()
.body(is(equalTo(new String(byteContent))))
.when().get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testGetNullFileVariable() {
String variableKey = "aVariableKey";
String filename = "test.txt";
String mimeType = "text/plain";
FileValue variableValue = Variables.fileValue(filename).mimeType(mimeType).create();
when(taskServiceMock.getVariableLocalTyped(eq(MockProvider.EXAMPLE_TASK_ID), eq(variableKey), anyBoolean()))
.thenReturn(variableValue);
given()
.pathParam("id", MockProvider.EXAMPLE_TASK_ID)
.pathParam("varId", variableKey)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.contentType(ContentType.TEXT.toString())
.and()
.body(is(equalTo("")))
.when().get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testCaseTaskGetVariableLocalTyped() {
// given
createCaseInstanceByKey(CASE_KEY, getVariables());
String taskId = selectSingleTask().getId();
disableAuthorization();
taskService.setVariablesLocal(taskId, getVariables());
enableAuthorization();
// when
TypedValue typedValue = taskService.getVariableLocalTyped(taskId, VARIABLE_NAME);
// then
assertNotNull(typedValue);
assertEquals(VARIABLE_VALUE, typedValue.getValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testProcessTaskGetVariableLocalTypedWithReadInstancePermissionOnAnyProcessDefinition() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_TASK);
disableAuthorization();
taskService.setVariablesLocal(taskId, getVariables());
enableAuthorization();
// when
TypedValue typedValue = taskService.getVariableLocalTyped(taskId, VARIABLE_NAME);
// then
assertNotNull(typedValue);
assertEquals(VARIABLE_VALUE, typedValue.getValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskGetVariableLocalTypedWithReadPermissionOnTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, taskId, userId, READ);
disableAuthorization();
taskService.setVariables(taskId, getVariables());
enableAuthorization();
// when
TypedValue typedValue = taskService.getVariableLocalTyped(taskId, VARIABLE_NAME);
// then
assertNotNull(typedValue);
assertEquals(VARIABLE_VALUE, typedValue.getValue());
deleteTask(taskId, true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testStandaloneTaskGetVariableLocalTypedWithReadPermissionOnAnyTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, ANY, userId, READ);
disableAuthorization();
taskService.setVariables(taskId, getVariables());
enableAuthorization();
// when
TypedValue typedValue = taskService.getVariableLocalTyped(taskId, VARIABLE_NAME);
// then
assertNotNull(typedValue);
assertEquals(VARIABLE_VALUE, typedValue.getValue());
deleteTask(taskId, true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testProcessTaskGetVariableLocalTypedWithReadPermissionOnTask() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
createGrantAuthorization(TASK, taskId, userId, READ);
disableAuthorization();
taskService.setVariablesLocal(taskId, getVariables());
enableAuthorization();
// when
TypedValue typedValue = taskService.getVariableLocalTyped(taskId, VARIABLE_NAME);
// then
assertNotNull(typedValue);
assertEquals(VARIABLE_VALUE, typedValue.getValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testProcessTaskGetVariableLocalTypedWithReadPermissionOnAnyTask() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
createGrantAuthorization(TASK, ANY, userId, READ);
disableAuthorization();
taskService.setVariablesLocal(taskId, getVariables());
enableAuthorization();
// when
TypedValue typedValue = taskService.getVariableLocalTyped(taskId, VARIABLE_NAME);
// then
assertNotNull(typedValue);
assertEquals(VARIABLE_VALUE, typedValue.getValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testProcessTaskGetVariableLocalTypedWithReadInstancePermissionOnProcessDefinition() {
// given
startProcessInstanceByKey(PROCESS_KEY);
String taskId = selectSingleTask().getId();
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_TASK);
disableAuthorization();
taskService.setVariablesLocal(taskId, getVariables());
enableAuthorization();
// when
TypedValue typedValue = taskService.getVariableLocalTyped(taskId, VARIABLE_NAME);
// then
assertNotNull(typedValue);
assertEquals(VARIABLE_VALUE, typedValue.getValue());
}
内容来源于网络,如有侵权,请联系作者删除!