org.camunda.bpm.engine.authorization.Authorization.setResourceType()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(117)

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

Authorization.setResourceType介绍

[英]sets the type of the resource
[中]设置资源的类型

代码示例

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

@Test
public void testCreateGrantAuthorization() {
 Authorization authorization = MockProvider.createMockGrantAuthorization();
 when(authorizationServiceMock.createNewAuthorization(Authorization.AUTH_TYPE_GRANT)).thenReturn(authorization);
 when(authorizationServiceMock.saveAuthorization(authorization)).thenReturn(authorization);
 AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
 when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
 when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
 when(authorizationQuery.singleResult()).thenReturn(authorization);
 AuthorizationDto dto = AuthorizationDto.fromAuthorization(authorization);
 given()
   .body(dto).contentType(ContentType.JSON)
 .then().expect()
   .statusCode(Status.OK.getStatusCode())
 .when()
   .post(AUTH_CREATE_PATH);
 verify(authorizationServiceMock).createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
 verify(authorization, times(2)).setUserId(authorization.getUserId());
 verify(authorization, times(4)).setResourceType(authorization.getAuthorizationType());
 verify(authorization, times(2)).setResourceId(authorization.getResourceId());
 verify(authorization, times(2)).setPermissions(authorization.getPermissions(Permissions.values()));
 verify(authorizationServiceMock).saveAuthorization(authorization);
}

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

@Test
public void testCreateRevokeAuthorization() {
 Authorization authorization = MockProvider.createMockRevokeAuthorization();
 when(authorizationServiceMock.createNewAuthorization(Authorization.AUTH_TYPE_REVOKE)).thenReturn(authorization);
 when(authorizationServiceMock.saveAuthorization(authorization)).thenReturn(authorization);
 AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
 when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
 when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
 when(authorizationQuery.singleResult()).thenReturn(authorization);
 AuthorizationDto dto = AuthorizationDto.fromAuthorization(authorization);
 given()
   .body(dto).contentType(ContentType.JSON)
 .then().expect()
   .statusCode(Status.OK.getStatusCode())
 .when()
   .post(AUTH_CREATE_PATH);
 verify(authorizationServiceMock).createNewAuthorization(Authorization.AUTH_TYPE_REVOKE);
 verify(authorization, times(2)).setUserId(authorization.getUserId());
 verify(authorization, times(4)).setResourceType(authorization.getAuthorizationType());
 verify(authorization, times(2)).setResourceId(authorization.getResourceId());
 verify(authorization, times(2)).setPermissions(authorization.getPermissions(Permissions.values()));
 verify(authorizationServiceMock).saveAuthorization(authorization);
}

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

@Test
public void testCreateGlobalAuthorization() {
 Authorization authorization = MockProvider.createMockGlobalAuthorization();
 when(authorizationServiceMock.createNewAuthorization(Authorization.AUTH_TYPE_GLOBAL)).thenReturn(authorization);
 when(authorizationServiceMock.saveAuthorization(authorization)).thenReturn(authorization);
 AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
 when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
 when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
 when(authorizationQuery.singleResult()).thenReturn(authorization);
 AuthorizationDto dto = AuthorizationDto.fromAuthorization(authorization);
 given()
   .body(dto).contentType(ContentType.JSON)
 .then().expect()
   .statusCode(Status.OK.getStatusCode())
 .when()
   .post(AUTH_CREATE_PATH);
 verify(authorizationServiceMock).createNewAuthorization(Authorization.AUTH_TYPE_GLOBAL);
 verify(authorization).setUserId(Authorization.ANY);
 verify(authorization, times(4)).setResourceType(authorization.getAuthorizationType());
 verify(authorization, times(2)).setResourceId(authorization.getResourceId());
 verify(authorization, times(2)).setPermissions(authorization.getPermissions(Permissions.values()));
 verify(authorizationServiceMock).saveAuthorization(authorization);
}

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

public static void update(AuthorizationCreateDto dto, Authorization dbAuthorization) {
 
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceType(dto.getResourceType());
 dbAuthorization.setResourceId(dto.getResourceId());
 dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 
}

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

public static void update(AuthorizationCreateDto dto, Authorization dbAuthorization) {
 
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceType(dto.getResourceType());
 dbAuthorization.setResourceId(dto.getResourceId());
 dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 
}

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

@Test
public void testUpdateAuthorization() {
 Authorization authorization = MockProvider.createMockGlobalAuthorization();
 AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
 when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
 when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
 when(authorizationQuery.singleResult()).thenReturn(authorization);
 AuthorizationDto dto = AuthorizationDto.fromAuthorization(authorization);
 given()
   .pathParam("id", MockProvider.EXAMPLE_AUTHORIZATION_ID)
   .body(dto).contentType(ContentType.JSON)
 .then().expect()
   .statusCode(Status.NO_CONTENT.getStatusCode())
 .when()
   .put(AUTH_RESOURCE_PATH);
 verify(authorizationQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID);
 verify(authorization).setGroupId(dto.getGroupId());
 verify(authorization).setUserId(dto.getUserId());
 verify(authorization).setResourceId(dto.getResourceId());
 verify(authorization).setResourceType(dto.getResourceType());
 verify(authorizationServiceMock).saveAuthorization(authorization);
}

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

public static void update(AuthorizationDto dto, Authorization dbAuthorization) {
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceId(dto.getResourceId());
 // update optional fields
 if(dto.getResourceType() != null) {
  dbAuthorization.setResourceType(dto.getResourceType());
 }
 if(dto.getPermissions() != null) {
  dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 }
}

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

public static void update(AuthorizationDto dto, Authorization dbAuthorization) {
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceId(dto.getResourceId());
 // update optional fields
 if(dto.getResourceType() != null) {
  dbAuthorization.setResourceType(dto.getResourceType());
 }
 if(dto.getPermissions() != null) {
  dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions(), dto.getResourceType()));
 }
}

代码示例来源:origin: org.camunda.bpm/camunda-engine-rest-jaxrs2

public static void update(AuthorizationCreateDto dto, Authorization dbAuthorization) {
 
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceType(dto.getResourceType());
 dbAuthorization.setResourceId(dto.getResourceId());
 dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions()));
 
}

代码示例来源:origin: org.camunda.bpm/camunda-engine-rest-jaxrs2

public static void update(AuthorizationDto dto, Authorization dbAuthorization) {
 dbAuthorization.setGroupId(dto.getGroupId());
 dbAuthorization.setUserId(dto.getUserId());
 dbAuthorization.setResourceId(dto.getResourceId());
 // update optional fields
 if(dto.getResourceType() != null) {
  dbAuthorization.setResourceType(dto.getResourceType());
 }
 if(dto.getPermissions() != null) {
  dbAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(dto.getPermissions()));
 }
}

相关文章