@Test public void testCreate() { when(dbStackConverter.convert(allocateRequest, USER_CRN)).thenReturn(dbStack); DBStack savedDBStack = new DBStack(); when(creationService.launchDatabaseServer(dbStack, CLUSTER_CRN)).thenReturn(savedDBStack); when(converterUtil.convert(savedDBStack, DatabaseServerStatusV4Response.class)) .thenReturn(allocateResponse); DatabaseServerStatusV4Response response = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.create(allocateRequest)); assertEquals(allocateResponse, response); verify(creationService).launchDatabaseServer(dbStack, CLUSTER_CRN); }
@Override @CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER) public DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request) { DBStack dbStack = dbStackConverter.convert(request, ThreadBasedUserCrnProvider.getUserCrn()); DBStack savedDBStack = redbeamsCreationService.launchDatabaseServer(dbStack, request.getClusterCrn()); return converterUtil.convert(savedDBStack, DatabaseServerStatusV4Response.class); }
DatabaseServerV4Controller implements DatabaseServerV4Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER) public DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request) { DBStack dbStack = dbStackConverter.convert(request, ThreadBasedUserCrnProvider.getUserCrn()); DBStack savedDBStack = redbeamsCreationService.launchDatabaseServer(dbStack, request.getClusterCrn()); return converterUtil.convert(savedDBStack, DatabaseServerStatusV4Response.class); } }
DatabaseServerV4Controller implements DatabaseServerV4Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER) public DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request) { DBStack dbStack = dbStackConverter.convert(request, ThreadBasedUserCrnProvider.getUserCrn()); DBStack savedDBStack = redbeamsCreationService.launchDatabaseServer(dbStack, request.getClusterCrn()); return converterUtil.convert(savedDBStack, DatabaseServerStatusV4Response.class); }  }
DatabaseServerV4Controller implements DatabaseServerV4Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER) public DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request) { DBStack dbStack = dbStackConverter.convert(request, ThreadBasedUserCrnProvider.getUserCrn()); DBStack savedDBStack = redbeamsCreationService.launchDatabaseServer(dbStack, request.getClusterCrn()); return converterUtil.convert(savedDBStack, DatabaseServerStatusV4Response.class); }  @Override @DisableCheckPermissions DatabaseServerV4Responses list(String environmentCrn); @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_DATABASE_SERVER) DatabaseServerV4Response getByName(String environmentCrn, @ResourceName String name); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_DATABASE_SERVER) DatabaseServerV4Response getByCrn(@ResourceCrn String crn); @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER) DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Response release(@ResourceCrn String crn); @CheckPermissionByAccount(action = AuthorizationResourceAction.REGISTER_DATABASE_SERVER) DatabaseServerV4Response register(DatabaseServerV4Request request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Response deleteByCrn(@ResourceCrn String crn, boolean force); @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Response deleteByName(String environmentCrn, @ResourceName String name, boolean force); @Override @CheckPermissionByResourceCrnList(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Responses deleteMultiple(@ResourceCrnList Set<String> crns, boolean force); @Override @DisableCheckPermissions DatabaseServerTestV4Response test(DatabaseServerTestV4Request request); @Override @CheckPermissionByResourceObject CreateDatabaseV4Response createDatabase(@ResourceObject CreateDatabaseV4Request request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.START_DATABASE_SERVER) void start(@ResourceCrn @ValidCrn @NotNull String crn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.STOP_DATABASE_SERVER) void stop(@ResourceCrn @ValidCrn @NotNull String crn); }
DatabaseServerV4Controller implements DatabaseServerV4Endpoint { @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER) public DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request) { DBStack dbStack = dbStackConverter.convert(request, ThreadBasedUserCrnProvider.getUserCrn()); DBStack savedDBStack = redbeamsCreationService.launchDatabaseServer(dbStack, request.getClusterCrn()); return converterUtil.convert(savedDBStack, DatabaseServerStatusV4Response.class); }  @Override @DisableCheckPermissions DatabaseServerV4Responses list(String environmentCrn); @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_DATABASE_SERVER) DatabaseServerV4Response getByName(String environmentCrn, @ResourceName String name); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_DATABASE_SERVER) DatabaseServerV4Response getByCrn(@ResourceCrn String crn); @Override @CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATABASE_SERVER) DatabaseServerStatusV4Response create(AllocateDatabaseServerV4Request request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Response release(@ResourceCrn String crn); @CheckPermissionByAccount(action = AuthorizationResourceAction.REGISTER_DATABASE_SERVER) DatabaseServerV4Response register(DatabaseServerV4Request request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Response deleteByCrn(@ResourceCrn String crn, boolean force); @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Response deleteByName(String environmentCrn, @ResourceName String name, boolean force); @Override @CheckPermissionByResourceCrnList(action = AuthorizationResourceAction.DELETE_DATABASE_SERVER) DatabaseServerV4Responses deleteMultiple(@ResourceCrnList Set<String> crns, boolean force); @Override @DisableCheckPermissions DatabaseServerTestV4Response test(DatabaseServerTestV4Request request); @Override @CheckPermissionByResourceObject CreateDatabaseV4Response createDatabase(@ResourceObject CreateDatabaseV4Request request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.START_DATABASE_SERVER) void start(@ResourceCrn @ValidCrn @NotNull String crn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.STOP_DATABASE_SERVER) void stop(@ResourceCrn @ValidCrn @NotNull String crn);  }