org.apache.http.HttpStatus.SC_CONFLICT

Here are the examples of the java api org.apache.http.HttpStatus.SC_CONFLICT taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

86 Examples 7

18 Source : EndToEndTest.java
with Apache License 2.0
from drm317

@Test
public void testC_CreatingADuplicateOrderCausesAConflict() {
    given().port(PORT_FOR_GATEWAY).header("Content-Type", "application/json").when().post(ORDERS_CMD_BASE_PATH + CMD_ORDER_CREATE + "/{id}?description={description}", id, description).then().statusCode(HttpStatus.SC_CONFLICT);
}

17 Source : RepositoriesITCase.java
with MIT License
from scm-manager

@Test
public void shouldRejectMultipleCreations() {
    String repositoryJson = repositoryJson(repositoryType);
    given(VndMediaType.REPOSITORY).body(repositoryJson).when().post(createResourceUrl("repositories")).then().statusCode(HttpStatus.SC_CONFLICT);
}

17 Source : AuditApiActionTest.java
with Apache License 2.0
from opendistro-for-elasticsearch

private void testReadonlyBoolean(final ObjectNode json, final String config, final String resource) throws Exception {
    final String resourcePath = "/config" + config + "/" + resource;
    ((ObjectNode) json.at(config)).put(resource, true);
    testPutRequest(json, HttpStatus.SC_OK, true);
    ((ObjectNode) json.at(config)).put(resource, false);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testBooleanPatch(resourcePath, false, HttpStatus.SC_CONFLICT, adminCredsHeader);
    ((ObjectNode) json.at(config)).put(resource, true);
    testPutRequest(json, HttpStatus.SC_OK, true);
    testBooleanPatch(resourcePath, true, HttpStatus.SC_OK, adminCredsHeader);
    testBooleanPatch(resourcePath, true, HttpStatus.SC_OK, adminCredsHeader);
}

16 Source : ApiExceptionTest.java
with Apache License 2.0
from onap

@Test
public void testVfModuleNotFoundException() throws ApiException {
    thrown.expect(VfModuleNotFoundException.clreplaced);
    thrown.expectMessage("Test Message");
    thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_CONFLICT)));
    thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER)));
    VfModuleNotFoundException testException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).httpResponseCode(HttpStatus.SC_CONFLICT).build();
    throw testException;
}

16 Source : UsersResourceIntegrationTest.java
with MIT License
from diegocamara

@Test
public void givenAPersistedUser_whenCallingRegisterUserEndpointWithExistingUsername_thenReturnCode409() throws JsonProcessingException {
    String userPreplacedword = "123";
    final var user = createUserEnreplacedy("user1", "[email protected]", "bio", "image", userPreplacedword);
    NewUserRequest newUser = new NewUserRequest();
    newUser.setUsername(user.getUsername());
    newUser.setEmail("[email protected]");
    newUser.setPreplacedword("user123");
    given().contentType(MediaType.APPLICATION_JSON).body(objectMapper.writeValuereplacedtring(newUser)).when().post(USERS_RESOURCE_PATH).then().statusCode(HttpStatus.SC_CONFLICT).body("errors.body", hasItems("username already exists"));
}

16 Source : UsersResourceIntegrationTest.java
with MIT License
from diegocamara

@Test
public void givenAPersistedUser_whenCallingRegisterUserEndpointWithExistingEmail_thenReturnCode409() throws JsonProcessingException {
    String userPreplacedword = "123";
    final var user = createUserEnreplacedy("user1", "[email protected]", "bio", "image", userPreplacedword);
    NewUserRequest newUser = new NewUserRequest();
    newUser.setUsername("user2");
    newUser.setEmail(user.getEmail());
    newUser.setPreplacedword("user123");
    given().contentType(MediaType.APPLICATION_JSON).body(objectMapper.writeValuereplacedtring(newUser)).when().post(USERS_RESOURCE_PATH).then().statusCode(HttpStatus.SC_CONFLICT).body("errors.body", hasItems("email already exists"));
}

16 Source : UserResourceIntegrationTest.java
with MIT License
from diegocamara

@Test
public void givenAnotherExistingEmail_whenExecuteUpdateUserEndpoint_shouldReturn409() throws JsonProcessingException {
    final var otherUser = createUserEnreplacedy("user", "[email protected]", "bio", "image", "123");
    final var currentUser = createUserEnreplacedy("currentUser", "[email protected]", "bio", "image", "123");
    String authorizationHeader = AUTHORIZATION_HEADER_VALUE_PREFIX + token(currentUser);
    UpdateUserRequest updateUserRequest = new UpdateUserRequest();
    updateUserRequest.setEmail(otherUser.getEmail());
    given().contentType(MediaType.APPLICATION_JSON).header(AUTHORIZATION_HEADER, authorizationHeader).body(objectMapper.writeValuereplacedtring(updateUserRequest)).put(USER_RESOURCE_PATH).then().statusCode(HttpStatus.SC_CONFLICT).body("errors.body", hasItems("email already exists"));
}

16 Source : UserResourceIntegrationTest.java
with MIT License
from diegocamara

@Test
public void givenAnotherExistingUsername_whenExecuteUpdateUserEndpoint_shouldReturn409() throws JsonProcessingException {
    final var otherUser = createUserEnreplacedy("user", "[email protected]", "bio", "image", "123");
    final var currentUser = createUserEnreplacedy("currentUser", "[email protected]", "bio", "image", "123");
    String authorizationHeader = AUTHORIZATION_HEADER_VALUE_PREFIX + token(currentUser);
    UpdateUserRequest updateUserRequest = new UpdateUserRequest();
    updateUserRequest.setUsername(otherUser.getUsername());
    given().contentType(MediaType.APPLICATION_JSON).header(AUTHORIZATION_HEADER, authorizationHeader).body(objectMapper.writeValuereplacedtring(updateUserRequest)).put(USER_RESOURCE_PATH).then().statusCode(HttpStatus.SC_CONFLICT).body("errors.body", hasItems("username already exists"));
}

15 Source : RoleViaNPTest.java
with Apache License 2.0
from personium

/**
 * RelationからNP経由でRoleの登録で同じ名前のRoleが既に存在する場合409となること.
 * @throws ParseException リクエストボディのパースに失敗
 */
@Test
public void RelationからNP経由でRoleの登録で同じ名前のRoleが既に存在する場合409となること() throws ParseException {
    String roleName = "RoleViaNPTestRole";
    String relationName = "RoleViaNPTestRelation";
    try {
        // Role作成
        CellCtlUtils.createRole(CELL_NAME, roleName);
        // Relation作成
        CellCtlUtils.createRelation(CELL_NAME, relationName);
        // Relation-RoleNP経由登録
        RoleUtils.createViaNP(CELL_NAME, MASTER_TOKEN_NAME, "Relation", RelationUtils.keyString(relationName), roleName, HttpStatus.SC_CONFLICT);
    } finally {
        // Role削除
        RoleUtils.delete(CELL_NAME, MASTER_TOKEN_NAME, roleName, null, -1);
        // Relation削除
        RelationUtils.delete(CELL_NAME, MASTER_TOKEN_NAME, relationName, null, -1);
    }
}

15 Source : BoxRoleLinkTest.java
with Apache License 2.0
from personium

/**
 * すでにlinksが登録されているBoxに再度Roleを登録した場合responseが409であること.
 */
@Test
public final void すでにlinksが登録されているBoxに再度Roleを登録した場合responseが409であること() {
    try {
        createLink();
        // 再度同一のリクエストを実行して409になることを確認
        Http.request("links-create.txt").with("token", AbstractCase.MASTER_TOKEN_NAME).with("cellName", CELL_NAME).with("enreplacedySet", ENreplacedY_SET_BOX).with("key", KEY).with("navProp", NAV_PROP_ROLE).with("uri", UrlUtils.cellCtlWithoutSingleQuote(CELL_NAME, ENreplacedY_SET_ROLE, roleChangedKey)).returns().statusCode(HttpStatus.SC_CONFLICT);
    } finally {
        deleteLink();
    }
}

15 Source : AuditApiActionTest.java
with Apache License 2.0
from opendistro-for-elasticsearch

private void testReadonlyList(final ObjectNode json, final String config, final String resource) throws Exception {
    final String resourcePath = "/config" + config + "/" + resource;
    ((ObjectNode) json.at(config)).putPOJO(resource, ImmutableList.of("test-resource-1", "test-resource-2"));
    testPutRequest(json, HttpStatus.SC_OK, true);
    // change order
    List<String> testList = ImmutableList.of("test-resource-2", "test-resource-1");
    ((ObjectNode) json.at(config)).putPOJO(resource, testList);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testList(resourcePath, testList, HttpStatus.SC_CONFLICT, adminCredsHeader);
    // change values
    testList = ImmutableList.of("test-resource-3", "test-resource-4");
    ((ObjectNode) json.at(config)).putPOJO(resource, testList);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testList(resourcePath, testList, HttpStatus.SC_CONFLICT, adminCredsHeader);
    // change values
    testList = Collections.emptyList();
    ((ObjectNode) json.at(config)).putPOJO(resource, testList);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testList(resourcePath, testList, HttpStatus.SC_CONFLICT, adminCredsHeader);
}

15 Source : AuditApiActionTest.java
with Apache License 2.0
from opendistro-for-elasticsearch

private void testReadonlyCategories(final ObjectNode json, final String config, final String resource) throws Exception {
    final String resourcePath = "/config" + config + "/" + resource;
    // change disabled_rest_categories readonly property
    ((ObjectNode) json.at(config)).putPOJO(resource, ImmutableList.of("SSL_EXCEPTION", "AUTHENTICATED"));
    testPutRequest(json, HttpStatus.SC_OK, true);
    // change order
    List<String> testList = ImmutableList.of("AUTHENTICATED", "SSL_EXCEPTION");
    ((ObjectNode) json.at(config)).putPOJO(resource, testList);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testList(resourcePath, testList, HttpStatus.SC_CONFLICT, adminCredsHeader);
    // change values
    testList = ImmutableList.of("AUTHENTICATED", "SSL_EXCEPTION", "FAILED_LOGIN");
    ((ObjectNode) json.at(config)).putPOJO(resource, testList);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testList(resourcePath, testList, HttpStatus.SC_CONFLICT, adminCredsHeader);
    // change values
    testList = null;
    ((ObjectNode) json.at(config)).putPOJO(resource, testList);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testList(resourcePath, testList, HttpStatus.SC_CONFLICT, adminCredsHeader);
}

15 Source : AbstractEventEndpointTest.java
with Educational Community License v2.0
from opencast

@Test
public void testApplyAclToEvent() throws Exception {
    // post nothing
    given().expect().statusCode(HttpStatus.SC_BAD_REQUEST).when().post(rt.host("notExists/access"));
    // invalid acl format
    given().formParam("acl", "INVALID").expect().statusCode(HttpStatus.SC_BAD_REQUEST).when().post(rt.host("asdasd/access"));
    // post an acl update
    String acl = "{\"acl\":{\"ace\":[{\"allow\":true,\"role\":\"ROLE_ADMIN\",\"action\":\"read\"},{\"allow\":true,\"role\":\"ROLE_ADMIN\",\"action\":\"write\"}]}}";
    given().formParam("acl", acl).expect().statusCode(HttpStatus.SC_OK).when().post(rt.host("asdasd/access"));
    // post an acl update for an scheduled event
    given().formParam("acl", acl).expect().statusCode(HttpStatus.SC_OK).when().post(rt.host("asdasd/access"));
    // post an acl update for an archived event
    given().formParam("acl", acl).expect().statusCode(HttpStatus.SC_OK).when().post(rt.host("archivedid/access"));
    // post an acl update for an workflow event - conflict
    given().formParam("acl", acl).expect().statusCode(HttpStatus.SC_CONFLICT).when().post(rt.host("workflowid/access"));
}

15 Source : ApiExceptionMapperTest.java
with Apache License 2.0
from onap

@Test
public void testVFModuleResponse() {
    VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_BAD_PARAMETER).build();
    Response resp = mapper.toResponse((ApiException) vfModuleException);
    replacedertEquals(resp.getStatus(), HttpStatus.SC_CONFLICT);
}

14 Source : AuditApiActionTest.java
with Apache License 2.0
from opendistro-for-elasticsearch

private void testReadonlyMap(final ObjectNode json, final String config, final String resource) throws Exception {
    final String resourcePath = "/config" + config + "/" + resource;
    ((ObjectNode) json.at(config)).putPOJO(resource, ImmutableMap.of("test-read-index-1", Collections.singletonList("test-field-1"), "test-read-index-2", Collections.singletonList("test-field-2")));
    testPutRequest(json, HttpStatus.SC_OK, true);
    // change values
    Map<String, List<String>> testMap = ImmutableMap.of("test-read-index-1", Collections.singletonList("test-field-1"));
    ((ObjectNode) json.at(config)).putPOJO(resource, testMap);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testMap(resourcePath, testMap, HttpStatus.SC_CONFLICT, adminCredsHeader);
    // change values
    testMap = ImmutableMap.of("test-read-index-1", ImmutableList.of("test-field-1", "test-field-2"));
    ((ObjectNode) json.at(config)).putPOJO(resource, testMap);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testMap(resourcePath, testMap, HttpStatus.SC_CONFLICT, adminCredsHeader);
    // change values
    testMap = ImmutableMap.of("test-read-index", ImmutableList.of("test-field"));
    ((ObjectNode) json.at(config)).putPOJO(resource, testMap);
    testPutRequest(json, HttpStatus.SC_CONFLICT, false, adminCredsHeader);
    testMap(resourcePath, testMap, HttpStatus.SC_CONFLICT, adminCredsHeader);
    // same object different order is valid
    testMap = ImmutableMap.of("test-read-index-2", Collections.singletonList("test-field-2"), "test-read-index-1", Collections.singletonList("test-field-1"));
    ((ObjectNode) json.at(config)).putPOJO(resource, testMap);
    testPutRequest(json, HttpStatus.SC_OK, false, adminCredsHeader);
    RestHelper.HttpResponse response = rh.executePatchRequest(ENDPOINT, "[{\"op\": \"add\",\"path\": \"" + resourcePath + "\",\"value\": " + writeValuereplacedtring(testMap, false) + "}]", adminCredsHeader);
    replacedertEquals(HttpStatus.SC_OK, response.getStatusCode());
}

14 Source : AbstractEventEndpointTest.java
with Educational Community License v2.0
from opencast

@Test
public void testGetNewConflicts() throws Exception {
    given().expect().statusCode(HttpStatus.SC_BAD_REQUEST).when().post(rt.host("new/conflicts"));
    given().formParam("metadata", "asdt").expect().statusCode(HttpStatus.SC_BAD_REQUEST).when().post(rt.host("new/conflicts"));
    String expected = IOUtils.toString(getClreplaced().getResource("/conflicts.json"));
    String metadataString = IOUtils.toString(getClreplaced().getResource("/conflictRequest.json"));
    String result = given().formParam("metadata", metadataString).expect().statusCode(HttpStatus.SC_CONFLICT).when().post(rt.host("new/conflicts")).replacedtring();
    replacedertThat(expected, SameJSONAs.sameJSONAs(result));
}

14 Source : UserCollectionResourceTest.java
with Apache License 2.0
from dingziyang

public void testCreateUserExceptions() throws Exception {
    // Create without ID
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("firstName", "Frederik");
    requestNode.put("lastName", "Heremans");
    requestNode.put("email", "[email protected]");
    HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION, "unexisting"));
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
    // Create when user already exists
    // Create without ID
    requestNode = objectMapper.createObjectNode();
    requestNode.put("id", "kermit");
    requestNode.put("firstName", "Frederik");
    requestNode.put("lastName", "Heremans");
    requestNode.put("email", "[email protected]");
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
}

14 Source : GroupCollectionResourceTest.java
with Apache License 2.0
from dingziyang

public void testCreateGroupExceptions() throws Exception {
    // Create without ID
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("name", "Test group");
    requestNode.put("type", "Test type");
    HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION));
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
    // Create when group already exists
    requestNode = objectMapper.createObjectNode();
    requestNode.put("id", "admin");
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
}

13 Source : DefaultBoxTest.java
with Apache License 2.0
from personium

/**
 * Main Box配下にデータが存在するとセルが削除できないことの確認.
 */
@Test
public final void MainBox配下にデータが存在するとセルが削除できないことの確認() {
    try {
        // セル作成
        CellUtils.create(CELL_NAME, TOKEN, HttpStatus.SC_CREATED);
        // Main Boxにコレクションを作成
        DavResourceUtils.createWebDavCollection("box/mkcol.txt", CELL_NAME, Box.MAIN_BOX_NAME + "/" + COL_NAME, TOKEN, HttpStatus.SC_CREATED);
        // Main Boxにコレクションがあるためセル削除が失敗すること
        CellUtils.delete(TOKEN, CELL_NAME, HttpStatus.SC_CONFLICT);
    } finally {
        // コレクションの削除
        DavResourceUtils.deleteCollection(CELL_NAME, Box.MAIN_BOX_NAME, COL_NAME, TOKEN, -1);
        // セル削除
        CellUtils.delete(TOKEN, CELL_NAME, -1);
    }
}

13 Source : EnginePropertiesResourceTest.java
with Apache License 2.0
from flowable

@Test
public void testCreateAlreadyExistingProperty() throws Exception {
    String originalPropertyValue = managementService.getProperties().get("schema.version");
    HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_ENGINE_PROPERTIES));
    ObjectNode requestNode = objectMapper.createObjectNode();
    // already exists
    requestNode.put("name", "schema.version");
    requestNode.put("value", "testValue");
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_CONFLICT);
    replacedertThat(managementService.getProperties().get("schema.version")).isEqualTo(originalPropertyValue);
}

13 Source : UserCollectionResourceTest.java
with Apache License 2.0
from flowable

@Test
public void testCreateUserExceptions() throws Exception {
    // Create without ID
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("firstName", "Frederik");
    requestNode.put("lastName", "Heremans");
    requestNode.put("email", "[email protected]");
    HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_COLLECTION, "unexisting"));
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
    // Create when user already exists
    // Create without ID
    requestNode = objectMapper.createObjectNode();
    requestNode.put("id", "kermit");
    requestNode.put("firstName", "Frederik");
    requestNode.put("lastName", "Heremans");
    requestNode.put("email", "[email protected]");
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
}

13 Source : GroupCollectionResourceTest.java
with Apache License 2.0
from flowable

@Test
public void testCreateGroupExceptions() throws Exception {
    // Create without ID
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("name", "Test group");
    requestNode.put("type", "Test type");
    HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION));
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
    // Create when group already exists
    requestNode = objectMapper.createObjectNode();
    requestNode.put("id", "admin");
    httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
}

12 Source : BoxRoleViaNPTest.java
with Apache License 2.0
from personium

/**
 * RoleからNP経由でBoxの登録でRoleが既に他のBoxと紐付いている場合409となること.
 */
@Test
public final void RoleからNP経由でBoxの登録でRoleが既に他のBoxと紐付いている場合409となること() {
    String roleName = "boxRoleNpTestRole";
    String boxName = "boxRoleNpTestBox";
    String baseBoxName = "boxRoleNpTestBaseBox";
    String requestBody = "{\"Name\":\"" + boxName + "\"}";
    try {
        // Role作成
        RoleUtils.create(CELL_NAME, TOKEN, roleName, HttpStatus.SC_CREATED);
        // Role-Box NP経由登録
        BoxUtils.createViaNP(TOKEN, CELL_NAME, "Role", RoleUtils.keyString(roleName), "{\"Name\":\"" + baseBoxName + "\"}");
        // Role-Box NP経由登録
        BoxUtils.createViaNP(TOKEN, CELL_NAME, "Role", RoleUtils.keyString(roleName, baseBoxName), requestBody, HttpStatus.SC_CONFLICT);
    } finally {
        // Role削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, baseBoxName, -1);
        // Box削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, -1);
        BoxUtils.delete(CELL_NAME, TOKEN, baseBoxName, -1);
    }
}

12 Source : BoxRoleViaNPTest.java
with Apache License 2.0
from personium

/**
 * RoleからNP経由でBoxの登録で同じ名前のBoxが既に存在する場合409となること.
 */
@Test
public final void RoleからNP経由でBoxの登録で同じ名前のBoxが既に存在する場合409となること() {
    String roleName = "boxRoleNpTestRole";
    String boxName = "boxRoleNpTestBox";
    String requestBody = "{\"Name\":\"" + boxName + "\"}";
    try {
        // Box作成
        BoxUtils.create(CELL_NAME, boxName, TOKEN);
        // Role作成
        RoleUtils.create(CELL_NAME, TOKEN, roleName, HttpStatus.SC_CREATED);
        // Role-Box NP経由登録
        BoxUtils.createViaNP(TOKEN, CELL_NAME, "Role", RoleUtils.keyString(roleName), requestBody, HttpStatus.SC_CONFLICT);
    } finally {
        // Role削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, null, -1);
        // Box削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, -1);
    }
}

12 Source : BoxRoleLinkTest.java
with Apache License 2.0
from personium

/**
 * RoleとLinkされているBoxを削除するとresponseが409であること.
 */
@Test
public final void RoleとLinkされているBoxを削除するとresponseが409であること() {
    String boxName = "roleLinkBox";
    String roleName = "boxLinkRole";
    try {
        // Boxの作成
        BoxUtils.create(CELL_NAME, boxName, TOKEN, HttpStatus.SC_CREATED);
        // 上のBoxと結びつくRole作成
        RoleUtils.create(CELL_NAME, TOKEN, roleName, boxName, HttpStatus.SC_CREATED);
        // Boxの削除(結びつくロールがあるため、409)
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, HttpStatus.SC_CONFLICT);
        // 結びつくロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, boxName, HttpStatus.SC_NO_CONTENT);
        // Boxの削除(結びつくロールが無くなったため、204)
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, HttpStatus.SC_NO_CONTENT);
    } finally {
        // 結びつくロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, boxName, -1);
        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, -1);
    }
}

12 Source : BoxRoleLinkTest.java
with Apache License 2.0
from personium

/**
 * BoxとRoleのLink追加時に複合キーの同名Roleが存在すると409になること.
 */
@Test
public final void BoxとRoleのLink追加時に複合キーの同名Roleが存在すると409になること() {
    final String boxName = "roleLinkBox";
    final String roleName = "boxLinkRole";
    try {
        // Boxの作成
        BoxUtils.create(CELL_NAME, boxName, TOKEN, HttpStatus.SC_CREATED);
        // 上のBoxと結びつくRole作成
        RoleUtils.create(CELL_NAME, TOKEN, roleName, boxName, HttpStatus.SC_CREATED);
        // 上のBoxと結びつかないRole作成
        RoleUtils.create(CELL_NAME, TOKEN, roleName, null, HttpStatus.SC_CREATED);
        String roleKeyName = "_Box.Name='" + boxName + "',Name='" + roleName + "'";
        // BoxとRoleのLink作成(複合キーのRoleが存在するため作成できない(409))
        createBoxRoleLink(boxName, roleName, HttpStatus.SC_CONFLICT);
        // RoleとBoxのLink作成(逆向きでも同様に409)
        createRoleBoxLink(roleName, boxName, HttpStatus.SC_CONFLICT);
        // ロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, null, HttpStatus.SC_NO_CONTENT);
        // BoxとRoleのLink削除
        deleteBoxRoleLink(boxName, roleKeyName, HttpStatus.SC_NO_CONTENT);
        // 結びつくロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, null, HttpStatus.SC_NO_CONTENT);
        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, HttpStatus.SC_NO_CONTENT);
    } finally {
        // 結びつくロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, boxName, -1);
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, null, -1);
        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, -1);
    }
}

12 Source : BoxRoleLinkTest.java
with Apache License 2.0
from personium

/**
 * BoxとRoleのLink削除時に単一キーの同名Roleが存在すると409になること.
 */
@Test
public final void BoxとRoleのLink削除時に単一キーの同名Roleが存在すると409になること() {
    final String boxName = "roleLinkBox";
    final String roleName = "boxLinkRole";
    try {
        // Boxの作成
        BoxUtils.create(CELL_NAME, boxName, TOKEN, HttpStatus.SC_CREATED);
        // 上のBoxと結びつくRole作成
        RoleUtils.create(CELL_NAME, TOKEN, roleName, boxName, HttpStatus.SC_CREATED);
        // 上のBoxと結びつかないRole作成
        RoleUtils.create(CELL_NAME, TOKEN, roleName, null, HttpStatus.SC_CREATED);
        String roleKeyName = "_Box.Name='" + boxName + "',Name='" + roleName + "'";
        // BoxとRoleのLink削除(単一キーのRoleが存在するため削除できない(409))
        deleteBoxRoleLink(boxName, roleKeyName, HttpStatus.SC_CONFLICT);
        // RoleとBoxのLink削除(逆向きでも同様に409)
        deleteRoleBoxLink(roleKeyName, boxName, HttpStatus.SC_CONFLICT);
        // ロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, null, HttpStatus.SC_NO_CONTENT);
        // BoxとRoleのLink削除(単一キーのRoleが存在しないので削除できる)
        deleteBoxRoleLink(boxName, roleKeyName, HttpStatus.SC_NO_CONTENT);
        // 結びつくロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, null, HttpStatus.SC_NO_CONTENT);
        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, HttpStatus.SC_NO_CONTENT);
    } finally {
        // 結びつくロールの削除
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, boxName, -1);
        RoleUtils.delete(CELL_NAME, TOKEN, roleName, null, -1);
        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, -1);
    }
}

12 Source : ComplexTypeUpdateTest.java
with Apache License 2.0
from personium

/**
 * 変名後のComplexTypeが存在する場合409になること.
 */
@Test
public final void 変名後のComplexTypeが存在する場合409になること() {
    String complexTypeName = "testComplexType";
    String complexTypeRename = "testComplexType2";
    try {
        // ComplexTypeの作成
        ComplexTypeUtils.create(Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA, complexTypeName, HttpStatus.SC_CREATED);
        ComplexTypeUtils.create(Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA, complexTypeRename, HttpStatus.SC_CREATED);
        // 変名
        TResponse res = ComplexTypeUtils.update(MASTER_TOKEN_NAME, Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA, complexTypeName, complexTypeRename, HttpStatus.SC_CONFLICT);
        res.checkErrorResponse(PersoniumCoreException.OData.ENreplacedY_ALREADY_EXISTS.getCode(), PersoniumCoreException.OData.ENreplacedY_ALREADY_EXISTS.getMessage());
    } finally {
        ComplexTypeUtils.delete(MASTER_TOKEN_NAME, Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA, complexTypeName, -1);
        ComplexTypeUtils.delete(MASTER_TOKEN_NAME, Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA, complexTypeRename, -1);
    }
}

12 Source : ProcessDefinitionResourceTest.java
with Apache License 2.0
from dingziyang

/**
 * Test activating already active process definition. POST repository/process-definitions/{processDefinitionId}
 */
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testActivateAlreadyActiveProcessDefinition() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    replacedertFalse(processDefinition.isSuspended());
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "activate");
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
    closeResponse(response);
}

11 Source : DeleteTest.java
with Apache License 2.0
from personium

/**
 * CellにBoxが存在する.
 */
@Test
public final void Cell削除のBoxが存在する時のテスト() {
    // Box作成
    this.boxCreate();
    // Cellを削除
    PersoniumRestAdapter rest = new PersoniumRestAdapter();
    PersoniumResponse res = null;
    // リクエストヘッダをセット
    HashMap<String, String> requestheaders = new HashMap<String, String>();
    requestheaders.put(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
    requestheaders.put(HttpHeaders.IF_MATCH, "*");
    try {
        // リクエスト
        // 本来は、LOCATIONヘッダにURLが格納されているが、jerseyTestFrameworkに向け直すため、再構築する
        res = rest.del(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME, this.cellInfo.cellId), requestheaders);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    // レスポンスコードのチェック
    replacedertEquals(HttpStatus.SC_CONFLICT, res.getStatusCode());
    replacedertEquals(MediaType.APPLICATION_JSON, res.getResponseHeaders(HttpHeaders.CONTENT_TYPE)[0].getValue());
}

11 Source : AssociationEndCreateTest.java
with Apache License 2.0
from personium

/**
 * replacedociationEndを新規作成_同名のreplacedociationEndが登録されている場合のテスト.
 */
@Test
public final void replacedociationEndを新規作成_同名のreplacedociationEndが登録されている場合のテスト() {
    Http.request("box/odatacol/schema/replacedocend/create.txt").with("cell", "testcell1").with("box", "box1").with("collection", "setodata").with("accept", MediaType.APPLICATION_JSON).with("contentType", MediaType.APPLICATION_JSON).with("token", PersoniumUnitConfig.getMasterToken()).with("name", replacedOCIATION_END_NAME).with("multiplicity", EdmMultiplicity.MANY.getSymbolString()).with("enreplacedyTypeName", ENreplacedY_TYPE_NAME).returns().statusCode(HttpStatus.SC_CREATED).debug();
    TResponse response = Http.request("box/odatacol/schema/replacedocend/create.txt").with("cell", "testcell1").with("box", "box1").with("collection", "setodata").with("accept", MediaType.APPLICATION_JSON).with("contentType", MediaType.APPLICATION_JSON).with("token", PersoniumUnitConfig.getMasterToken()).with("name", replacedOCIATION_END_NAME).with("multiplicity", EdmMultiplicity.MANY.getSymbolString()).with("enreplacedyTypeName", ENreplacedY_TYPE_NAME).returns().statusCode(HttpStatus.SC_CONFLICT).debug();
    // レスポンスヘッダーのチェック
    // Content-Type
    response.checkHeader(ODataConstants.Headers.CONTENT_TYPE, MediaType.APPLICATION_JSON);
    // replacedociationEndの削除
    deletereplacedociationEnd();
}

11 Source : ProcessDefinitionResourceTest.java
with Apache License 2.0
from dingziyang

/**
 * Test suspending already suspended process definition. POST repository/process-definitions/{processDefinitionId}
 */
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testSuspendAlreadySuspendedProcessDefinition() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    repositoryService.suspendProcessDefinitionById(processDefinition.getId());
    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    replacedertTrue(processDefinition.isSuspended());
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "suspend");
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
    closeResponse(response);
}

11 Source : GroupMembershipResourceTest.java
with Apache License 2.0
from dingziyang

public void testCreateMembershipAlreadyExisting() throws Exception {
    try {
        Group testGroup = idenreplacedyService.newGroup("testgroup");
        testGroup.setName("Test group");
        testGroup.setType("Test type");
        idenreplacedyService.saveGroup(testGroup);
        User testUser = idenreplacedyService.newUser("testuser");
        idenreplacedyService.saveUser(testUser);
        idenreplacedyService.createMembership("testuser", "testgroup");
        ObjectNode requestNode = objectMapper.createObjectNode();
        requestNode.put("userId", "testuser");
        HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_MEMBERSHIP_COLLECTION, "testgroup"));
        httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
        closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
    } finally {
        try {
            idenreplacedyService.deleteGroup("testgroup");
        } catch (Throwable ignore) {
        // Ignore, since the group may not have been created in the test
        // or already deleted
        }
        try {
            idenreplacedyService.deleteUser("testuser");
        } catch (Throwable ignore) {
        // Ignore, since the group may not have been created in the test
        // or already deleted
        }
    }
}

10 Source : ProcessDefinitionResourceTest.java
with Apache License 2.0
from flowable

/**
 * Test activating already active process definition. POST repository/process-definitions/{processDefinitionId}
 */
@Test
@Deployment(resources = { "org/flowable/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testActivateAlreadyActiveProcessDefinition() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    replacedertThat(processDefinition.isSuspended()).isFalse();
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "activate");
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
    closeResponse(response);
}

10 Source : GroupMembershipResourceTest.java
with Apache License 2.0
from flowable

@Test
public void testCreateMembershipAlreadyExisting() throws Exception {
    try {
        Group testGroup = idenreplacedyService.newGroup("testgroup");
        testGroup.setName("Test group");
        testGroup.setType("Test type");
        idenreplacedyService.saveGroup(testGroup);
        User testUser = idenreplacedyService.newUser("testuser");
        idenreplacedyService.saveUser(testUser);
        idenreplacedyService.createMembership("testuser", "testgroup");
        ObjectNode requestNode = objectMapper.createObjectNode();
        requestNode.put("userId", "testuser");
        HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_MEMBERSHIP_COLLECTION, "testgroup"));
        httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
        closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
    } finally {
        try {
            idenreplacedyService.deleteGroup("testgroup");
        } catch (Throwable ignore) {
        // Ignore, since the group may not have been created in the test
        // or already deleted
        }
        try {
            idenreplacedyService.deleteUser("testuser");
        } catch (Throwable ignore) {
        // Ignore, since the group may not have been created in the test
        // or already deleted
        }
    }
}

10 Source : UserInfoResourceTest.java
with Apache License 2.0
from dingziyang

public void testCreateUserInfoExceptions() throws Exception {
    User savedUser = null;
    try {
        User newUser = idenreplacedyService.newUser("testuser");
        newUser.setFirstName("Fred");
        newUser.setLastName("McDonald");
        newUser.setEmail("[email protected]");
        idenreplacedyService.saveUser(newUser);
        savedUser = newUser;
        // Test creating without value
        ObjectNode requestNode = objectMapper.createObjectNode();
        requestNode.put("key", "key1");
        HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO_COLLECTION, "testuser"));
        httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
        closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
        // Test creating without key
        requestNode = objectMapper.createObjectNode();
        requestNode.put("value", "The value");
        httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
        closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
        // Test creating an already existing info
        idenreplacedyService.setUserInfo(newUser.getId(), "key1", "The value");
        requestNode = objectMapper.createObjectNode();
        requestNode.put("key", "key1");
        requestNode.put("value", "The value");
        httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
        closeResponse(executeRequest(httpPost, HttpStatus.SC_CONFLICT));
        // Test creating info for unexisting user
        httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_INFO_COLLECTION, "unexistinguser"));
        httpPost.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
        closeResponse(executeRequest(httpPost, HttpStatus.SC_NOT_FOUND));
    } finally {
        // Delete user after test preplacedes or fails
        if (savedUser != null) {
            idenreplacedyService.deleteUser(savedUser.getId());
        }
    }
}

9 Source : ClientProxyTest.java
with MIT License
from SDA-SE

@Test
public void shouldNotUseProxy() {
    String url = String.format("localhost:%d", CONTENT_WIRE.port());
    // given: expect that the proxy is skipped
    CONTENT_WIRE.stubFor(get("/").withHeader(HttpHeaders.HOST, equalTo(url)).willReturn(aResponse().withStatus(409)));
    // when
    Response response = getClient("shouldNotUseProxy").target(CONTENT_WIRE.baseUrl()).request().get();
    // then
    replacedertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
    PROXY_WIRE.verify(0, RequestPatternBuilder.allRequests());
    CONTENT_WIRE.verify(1, RequestPatternBuilder.newRequestPattern(RequestMethod.GET, urlEqualTo("/")).withHeader(HttpHeaders.HOST, equalTo(url)));
}

9 Source : DeleteTest.java
with Apache License 2.0
from personium

/**
 * Cell削除のMessageが存在する時のテスト.
 */
@SuppressWarnings("unchecked")
@Test
public final void Cell削除のMessageが存在する時のテスト() {
    // 送信先CellUrl
    String receivedCell = "receivedcell";
    // リクエストボディ作成
    JSONObject body = new JSONObject();
    body.put("BoxBound", false);
    body.put("InReplyTo", null);
    body.put("To", UrlUtils.cellRoot(receivedCell));
    body.put("ToRelation", null);
    body.put("Type", "message");
    body.put("replacedle", "replacedle");
    body.put("Body", "body");
    body.put("Priority", 3);
    TResponse response = null;
    try {
        createCell(receivedCell);
        // メッセージ送信
        response = SentMessageUtils.sent(MASTER_TOKEN_NAME, this.cellInfo.cellName, body.toJSONString(), HttpStatus.SC_CREATED);
        // Cellを削除(SentMessage未削除のため、削除不可能)
        CellUtils.delete(MASTER_TOKEN_NAME, this.cellInfo.cellName, HttpStatus.SC_CONFLICT);
        // Cellを削除(ReceivedMessage未削除のため、削除不可能)
        CellUtils.delete(MASTER_TOKEN_NAME, receivedCell, HttpStatus.SC_CONFLICT);
        deleteOdataResource(response.getLocationHeader());
        // 自動生成された受信メッセージの削除
        MessageSentTest.deleteReceivedMessage(receivedCell, UrlUtils.cellRoot(this.cellInfo.cellName), "message", "replacedle", "body");
        // Cellを削除(SentMessage削除済のため、削除可能)
        CellUtils.delete(MASTER_TOKEN_NAME, this.cellInfo.cellName, HttpStatus.SC_NO_CONTENT);
        // Cellを削除(ReceivedMessage削除済のため、削除可能)
        CellUtils.delete(MASTER_TOKEN_NAME, receivedCell, HttpStatus.SC_NO_CONTENT);
    } finally {
        // Cellを削除(SentMessage削除済のため、削除可能)
        CellUtils.delete(MASTER_TOKEN_NAME, this.cellInfo.cellName, -1);
        // Cellを削除(ReceivedMessage削除済のため、削除可能)
        CellUtils.delete(MASTER_TOKEN_NAME, receivedCell, -1);
        // Cell作成
        CellUtils.create(this.cellInfo.cellName, MASTER_TOKEN_NAME, -1);
    }
}

9 Source : BoxRoleLinkTest.java
with Apache License 2.0
from personium

/**
 * RoleとBoxのlink登録で既に同じリンクが存在する場合409となること.
 */
@Test
public final void RoleとBoxのlink登録で既に同じリンクが存在する場合409となること() {
    String cellName = Setup.TEST_CELL1;
    String boxName = "RoleBoxLinkTestBox";
    String roleName = "RoleBoxLinkTestRole";
    try {
        // Role作成
        RoleUtils.create(cellName, TOKEN, roleName, HttpStatus.SC_CREATED);
        // Box作成
        BoxUtils.create(cellName, boxName, TOKEN);
        // Role-Box $links登録
        LinksUtils.createLinks(cellName, Role.EDM_TYPE_NAME, roleName, null, Box.EDM_TYPE_NAME, boxName, null, TOKEN, HttpStatus.SC_NO_CONTENT);
        LinksUtils.createLinks(cellName, Role.EDM_TYPE_NAME, roleName, boxName, Box.EDM_TYPE_NAME, boxName, null, TOKEN, HttpStatus.SC_CONFLICT);
    } finally {
        // Role削除
        RoleUtils.delete(cellName, TOKEN, roleName, boxName, -1);
        // Box削除
        BoxUtils.delete(cellName, TOKEN, boxName, -1);
    }
}

9 Source : BoxRoleLinkTest.java
with Apache License 2.0
from personium

/**
 * RoleとBoxのlink登録でRoleが既に他のBoxと紐付いている場合409となること.
 */
@Test
public final void RoleとBoxのlink登録でRoleが既に他のBoxと紐付いている場合409となること() {
    String cellName = Setup.TEST_CELL1;
    String baseBoxName = "RoleBoxLinkTestBaseBox";
    String boxName = "RoleBoxLinkTestBox";
    String roleName = "RoleBoxLinkTestRole";
    try {
        // Role作成
        RoleUtils.create(cellName, TOKEN, roleName, HttpStatus.SC_CREATED);
        // Box作成
        BoxUtils.create(cellName, baseBoxName, TOKEN);
        BoxUtils.create(cellName, boxName, TOKEN);
        // Role-Box $links登録
        LinksUtils.createLinks(cellName, Role.EDM_TYPE_NAME, roleName, null, Box.EDM_TYPE_NAME, baseBoxName, null, TOKEN, HttpStatus.SC_NO_CONTENT);
        LinksUtils.createLinks(cellName, Role.EDM_TYPE_NAME, roleName, baseBoxName, Box.EDM_TYPE_NAME, boxName, null, TOKEN, HttpStatus.SC_CONFLICT);
    } finally {
        // Role削除
        RoleUtils.delete(cellName, TOKEN, roleName, null, -1);
        RoleUtils.delete(cellName, TOKEN, roleName, baseBoxName, -1);
        // Box削除
        BoxUtils.delete(cellName, TOKEN, baseBoxName, -1);
        BoxUtils.delete(cellName, TOKEN, boxName, -1);
    }
}

9 Source : BoxRoleLinkTest.java
with Apache License 2.0
from personium

/**
 * RelationとLinkされているBoxを削除するとresponseが409であること.
 */
@SuppressWarnings("unchecked")
@Test
public final void RelationとLinkされているBoxを削除するとresponseが409であること() {
    String boxName = "relationLinkBox";
    String relationName = "boxLinkrelation";
    JSONObject body = new JSONObject();
    body.put("Name", relationName);
    body.put("_Box.Name", boxName);
    try {
        // Boxの作成
        BoxUtils.create(CELL_NAME, boxName, TOKEN, HttpStatus.SC_CREATED);
        // 上のBoxと結びつくRelation作成
        RelationUtils.create(CELL_NAME, TOKEN, body, HttpStatus.SC_CREATED);
        // Boxの削除(結びつくRelationがあるため、409)
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, HttpStatus.SC_CONFLICT);
        // 結びつくRelationの削除
        RelationUtils.delete(CELL_NAME, TOKEN, relationName, boxName, HttpStatus.SC_NO_CONTENT);
        // Boxの削除(結びつくRelationが無くなったため、204)
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, HttpStatus.SC_NO_CONTENT);
    } finally {
        // 結びつくRelationの削除
        RelationUtils.delete(CELL_NAME, TOKEN, relationName, boxName, -1);
        // Boxの削除
        BoxUtils.delete(CELL_NAME, TOKEN, boxName, -1);
    }
}

9 Source : BoxCrudTest.java
with Apache License 2.0
from personium

/**
 * Test of BOX update (MERGE).
 */
@SuppressWarnings("unchecked")
@Test
public void box_update_merge() {
    try {
        // create BOX1
        String etag1 = createBoxRequest(TEST_BOX_NAME, null).returns().statusCode(HttpStatus.SC_CREATED).getHeader(HttpHeaders.ETAG);
        // create Box2
        String etag2 = createBoxRequest(TEST_BOX_NAME_WITH_SCHEMA, null).returns().statusCode(HttpStatus.SC_CREATED).getHeader(HttpHeaders.ETAG);
        // Successful unique key(schema) change for Box2 (now with schema)
        JSONObject updateBody = new JSONObject();
        updateBody.put("Name", TEST_BOX_NAME_WITH_SCHEMA);
        updateBody.put("Schema", TEST_BOX_SCHEMA);
        etag2 = mergeBoxRequest(TEST_BOX_NAME_WITH_SCHEMA, etag2, updateBody.toJSONString()).returns().statusCode(HttpStatus.SC_NO_CONTENT).getHeader(HttpHeaders.ETAG);
        // Etag difference update of Box2 fails
        updateBody = new JSONObject();
        updateBody.put("Name", TEST_BOX_NAME);
        updateBody.put("Schema", TEST_BOX_SCHEMA);
        mergeBoxRequest(TEST_BOX_NAME_WITH_SCHEMA, etag1, updateBody.toJSONString(), HttpStatus.SC_PRECONDITION_FAILED);
        // Change primary key of Box 2 fails due to conflict.
        updateBody = new JSONObject();
        updateBody.put("Name", TEST_BOX_NAME);
        updateBody.put("Schema", TEST_BOX_SCHEMA);
        mergeBoxRequest(TEST_BOX_NAME_WITH_SCHEMA, etag2, updateBody.toJSONString(), HttpStatus.SC_CONFLICT);
        // Unique key(schema) changes in Box 1 fail due to conflict.
        updateBody = new JSONObject();
        updateBody.put("Name", TEST_BOX_NAME);
        updateBody.put("Schema", TEST_BOX_SCHEMA);
        mergeBoxRequest(TEST_BOX_NAME, etag1, updateBody.toJSONString(), HttpStatus.SC_CONFLICT);
        // Unique key(schema) change of Box 1 is successful
        updateBody = new JSONObject();
        updateBody.put("Name", TEST_BOX_NAME);
        updateBody.put("Schema", "http://example.net/hoge/");
        mergeBoxRequest(TEST_BOX_NAME, etag1, updateBody.toJSONString()).returns().statusCode(HttpStatus.SC_NO_CONTENT).getHeader(HttpHeaders.ETAG);
        // If the Body Name is not specified
        updateBody = new JSONObject();
        updateBody.put("Schema", null);
        mergeBoxRequest(TEST_BOX_NAME, "*", updateBody.toJSONString(), HttpStatus.SC_NO_CONTENT);
        // If the schema of Body is not specified
        updateBody = new JSONObject();
        updateBody.put("Name", TEST_BOX_NAME);
        mergeBoxRequest(TEST_BOX_NAME, "*", updateBody.toJSONString(), HttpStatus.SC_NO_CONTENT);
        // If the schema of Body is null, it will be updated with null
        updateBody = new JSONObject();
        updateBody.put("Name", TEST_BOX_NAME);
        updateBody.put("Schema", null);
        mergeBoxRequest(TEST_BOX_NAME, "*", updateBody.toJSONString(), HttpStatus.SC_NO_CONTENT);
        // It is an error if null is specified in the name
        updateBody = new JSONObject();
        updateBody.put("Name", null);
        updateBody.put("Schema", "http://example.net/hoge/");
        mergeBoxRequest(TEST_BOX_NAME, "*", updateBody.toJSONString(), HttpStatus.SC_BAD_REQUEST);
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        deleteBoxRequest(TEST_BOX_NAME_WITH_SCHEMA).returns();
        deleteBoxRequest(TEST_BOX_NAME).returns();
    }
}

9 Source : ServiceSchmaTest.java
with Apache License 2.0
from personium

// /**
// * リンク先のreplacedosiationを削除後にユーザのEDMXを取得した場合_削除されたリンク情報が取得できていないこと.
// */
// @Test
// public final void リンク先のreplacedosiationを削除後にユーザスキーマ情報を取得した場合_削除されたリンク情報が取得できていないこと() {
// }
// 
// /**
// * リンク先のEnreplacedyTypeを削除後ユーザのEDMXを取得した場合_削除されたリンク情報が取得できていないこと.
// */
// @Test
// public final void リンク先のEnreplacedyTypeを削除後ユーザのEDMXを取得した場合_削除されたリンク情報が取得できていないこと() {
// }
/**
 * replacedociationEndとLinkされているEnreplacedyTypeを削除するとresponseが409であること. TODO v1.1
 * PropertyとLinkされている、EnreplacedyTypeを削除するとresponseが409であること.のテストを追加
 */
@Test
public final void replacedociationEndとLinkされているEnreplacedyTypeを削除するとresponseが409であること() {
    String replacedociationEndName = "linkreplacedociationEnd";
    String enreplacedyTypeName = "linkEnreplacedyType";
    String odataSvcName = Setup.TEST_ODATA;
    String multiplicity = "1";
    try {
        // EnreplacedyTypeの作成
        EnreplacedyTypeUtils.create(Setup.TEST_CELL1, PersoniumUnitConfig.getMasterToken(), odataSvcName, enreplacedyTypeName, HttpStatus.SC_CREATED);
        // 上のEnreplacedyTypeと結びつくreplacedociationEnd作成
        replacedociationEndPost(Setup.TEST_CELL1, odataSvcName, enreplacedyTypeName, replacedociationEndName, multiplicity, HttpStatus.SC_CREATED);
        // EnreplacedyTypeの削除(結びつくEnreplacedyTypeがあるため、409)
        enreplacedyTypeDelete(Setup.TEST_CELL1, odataSvcName, enreplacedyTypeName, HttpStatus.SC_CONFLICT);
        // 結びつくEnreplacedyTypeの削除
        replacedociationEndUtils.delete(AbstractCase.MASTER_TOKEN_NAME, Setup.TEST_CELL1, odataSvcName, enreplacedyTypeName, Setup.TEST_BOX1, replacedociationEndName, HttpStatus.SC_NO_CONTENT);
        // EnreplacedyTypeの削除(結びつくEnreplacedyTypeが存在しないため、204)
        enreplacedyTypeDelete(Setup.TEST_CELL1, odataSvcName, enreplacedyTypeName, HttpStatus.SC_NO_CONTENT);
    } finally {
        // 結びつくEnreplacedyTypeの削除
        enreplacedyTypeDelete(Setup.TEST_CELL1, odataSvcName, enreplacedyTypeName, -1);
        // EnreplacedyTypeの削除
        replacedociationEndUtils.delete(AbstractCase.MASTER_TOKEN_NAME, Setup.TEST_CELL1, odataSvcName, enreplacedyTypeName, Setup.TEST_BOX1, replacedociationEndName, -1);
    }
}

9 Source : UserDataCreateWithNPTest.java
with Apache License 2.0
from personium

/**
 * リンクが0_1対0_1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること.
 */
@SuppressWarnings("unchecked")
@Test
public final void リンクが0_1対0_1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること() {
    String masterTokenName = AbstractCase.MASTER_TOKEN_NAME;
    String enreplacedyTypeName = "srcEnreplacedy";
    String navPropName = "tgtEnreplacedy";
    try {
        // スキーマ作成
        createSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName, "0..1", "0..1");
        // ソース側のユーザOData作成
        JSONObject body = new JSONObject();
        body.put("__id", "sourceNpCreateTest");
        UserDataUtils.create(masterTokenName, HttpStatus.SC_CREATED, body, cellName, boxName, colName, enreplacedyTypeName);
        getUserData(cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成
        JSONObject bodyNp1 = new JSONObject();
        bodyNp1.put("__id", "targetNpCreateTest");
        UserDataUtils.createViaNP(masterTokenName, bodyNp1, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CREATED);
        getUserData(cellName, boxName, colName, navPropName, "targetNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成(既にリンクデータが登録されているので409が返却されること)
        JSONObject bodyNp2 = new JSONObject();
        bodyNp2.put("__id", "testNp");
        UserDataUtils.createViaNP(masterTokenName, bodyNp2, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CONFLICT);
        // NP経由で登録しようとしたユーザODataが存在しないこと
        getUserData(cellName, boxName, colName, navPropName, "testNp", masterTokenName, HttpStatus.SC_NOT_FOUND);
    } finally {
        // ユーザデータの削除
        UserDataUtils.delete(masterTokenName, -1, enreplacedyTypeName, "sourceNpCreateTest", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "testNp", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "targetNpCreateTest", colName);
        deleteSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName);
    }
}

9 Source : UserDataCreateWithNPTest.java
with Apache License 2.0
from personium

/**
 * リンクが0_1対1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること.
 */
@SuppressWarnings("unchecked")
@Test
public final void リンクが0_1対1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること() {
    String masterTokenName = AbstractCase.MASTER_TOKEN_NAME;
    String enreplacedyTypeName = "srcEnreplacedy";
    String navPropName = "tgtEnreplacedy";
    try {
        // スキーマ作成
        createSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName, "0..1", "1");
        // ソース側のユーザOData作成
        JSONObject body = new JSONObject();
        body.put("__id", "sourceNpCreateTest");
        UserDataUtils.create(masterTokenName, HttpStatus.SC_CREATED, body, cellName, boxName, colName, enreplacedyTypeName);
        getUserData(cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成
        JSONObject bodyNp1 = new JSONObject();
        bodyNp1.put("__id", "targetNpCreateTest");
        UserDataUtils.createViaNP(masterTokenName, bodyNp1, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CREATED);
        getUserData(cellName, boxName, colName, navPropName, "targetNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成(既にリンクデータが登録されているので409が返却されること)
        JSONObject bodyNp2 = new JSONObject();
        bodyNp2.put("__id", "testNp");
        UserDataUtils.createViaNP(masterTokenName, bodyNp2, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CONFLICT);
        // NP経由で登録しようとしたユーザODataが存在しないこと
        getUserData(cellName, boxName, colName, navPropName, "testNp", masterTokenName, HttpStatus.SC_NOT_FOUND);
    } finally {
        // ユーザデータの削除
        UserDataUtils.delete(masterTokenName, -1, enreplacedyTypeName, "sourceNpCreateTest", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "testNp", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "targetNpCreateTest", colName);
        deleteSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName);
    }
}

9 Source : UserDataCreateWithNPTest.java
with Apache License 2.0
from personium

/**
 * リンクが1対0_1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること.
 */
@SuppressWarnings("unchecked")
@Test
public final void リンクが1対0_1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること() {
    String masterTokenName = AbstractCase.MASTER_TOKEN_NAME;
    String enreplacedyTypeName = "srcEnreplacedy";
    String navPropName = "tgtEnreplacedy";
    try {
        // スキーマ作成
        createSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName, "1", "0..1");
        // ソース側のユーザOData作成
        JSONObject body = new JSONObject();
        body.put("__id", "sourceNpCreateTest");
        UserDataUtils.create(masterTokenName, HttpStatus.SC_CREATED, body, cellName, boxName, colName, enreplacedyTypeName);
        getUserData(cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成
        JSONObject bodyNp1 = new JSONObject();
        bodyNp1.put("__id", "targetNpCreateTest");
        UserDataUtils.createViaNP(masterTokenName, bodyNp1, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CREATED);
        getUserData(cellName, boxName, colName, navPropName, "targetNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成(既にリンクデータが登録されているので409が返却されること)
        JSONObject bodyNp2 = new JSONObject();
        bodyNp2.put("__id", "testNp");
        UserDataUtils.createViaNP(masterTokenName, bodyNp2, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CONFLICT);
        // NP経由で登録しようとしたユーザODataが存在しないこと
        getUserData(cellName, boxName, colName, navPropName, "testNp", masterTokenName, HttpStatus.SC_NOT_FOUND);
    } finally {
        // ユーザデータの削除
        UserDataUtils.delete(masterTokenName, -1, enreplacedyTypeName, "sourceNpCreateTest", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "testNp", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "targetNpCreateTest", colName);
        deleteSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName);
    }
}

9 Source : UserDataCreateWithNPTest.java
with Apache License 2.0
from personium

/**
 * リンクがN対1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること.
 */
@SuppressWarnings("unchecked")
@Test
public final void リンクがN対1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること() {
    String masterTokenName = AbstractCase.MASTER_TOKEN_NAME;
    String enreplacedyTypeName = "srcEnreplacedy";
    String navPropName = "tgtEnreplacedy";
    try {
        // スキーマ作成
        createSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName, "*", "1");
        // ソース側のユーザOData作成
        JSONObject body = new JSONObject();
        body.put("__id", "sourceNpCreateTest");
        UserDataUtils.create(masterTokenName, HttpStatus.SC_CREATED, body, cellName, boxName, colName, enreplacedyTypeName);
        getUserData(cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成
        JSONObject bodyNp1 = new JSONObject();
        bodyNp1.put("__id", "targetNpCreateTest");
        UserDataUtils.createViaNP(masterTokenName, bodyNp1, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CREATED);
        getUserData(cellName, boxName, colName, navPropName, "targetNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成(既にリンクデータが登録されているので409が返却されること)
        JSONObject bodyNp2 = new JSONObject();
        bodyNp2.put("__id", "testNp");
        UserDataUtils.createViaNP(masterTokenName, bodyNp2, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CONFLICT);
        // NP経由で登録しようとしたユーザODataが存在しないこと
        getUserData(cellName, boxName, colName, navPropName, "testNp", masterTokenName, HttpStatus.SC_NOT_FOUND);
    } finally {
        // ユーザデータの削除
        UserDataUtils.delete(masterTokenName, -1, enreplacedyTypeName, "sourceNpCreateTest", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "testNp", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "targetNpCreateTest", colName);
        deleteSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName);
    }
}

9 Source : UserDataCreateWithNPTest.java
with Apache License 2.0
from personium

/**
 * リンクがN対0_1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること.
 */
@SuppressWarnings("unchecked")
@Test
public final void リンクがN対0_1のUserDataですでにリンクデータが存在する場合にNavigationProperty経由で新規作成して409が返却されること() {
    String masterTokenName = AbstractCase.MASTER_TOKEN_NAME;
    String enreplacedyTypeName = "srcEnreplacedy";
    String navPropName = "tgtEnreplacedy";
    try {
        // スキーマ作成
        createSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName, "*", "0..1");
        // ソース側のユーザOData作成
        JSONObject body = new JSONObject();
        body.put("__id", "sourceNpCreateTest");
        UserDataUtils.create(masterTokenName, HttpStatus.SC_CREATED, body, cellName, boxName, colName, enreplacedyTypeName);
        getUserData(cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成
        JSONObject bodyNp1 = new JSONObject();
        bodyNp1.put("__id", "targetNpCreateTest");
        UserDataUtils.createViaNP(masterTokenName, bodyNp1, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CREATED);
        getUserData(cellName, boxName, colName, navPropName, "targetNpCreateTest", masterTokenName, HttpStatus.SC_OK);
        // NavigationProperty側のユーザOData作成(既にリンクデータが登録されているので409が返却されること)
        JSONObject bodyNp2 = new JSONObject();
        bodyNp2.put("__id", "testNp");
        UserDataUtils.createViaNP(masterTokenName, bodyNp2, cellName, boxName, colName, enreplacedyTypeName, "sourceNpCreateTest", navPropName, HttpStatus.SC_CONFLICT);
        // NP経由で登録しようとしたユーザODataが存在しないこと
        getUserData(cellName, boxName, colName, navPropName, "testNp", masterTokenName, HttpStatus.SC_NOT_FOUND);
    } finally {
        // ユーザデータの削除
        UserDataUtils.delete(masterTokenName, -1, enreplacedyTypeName, "sourceNpCreateTest", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "testNp", colName);
        UserDataUtils.delete(masterTokenName, -1, navPropName, "targetNpCreateTest", colName);
        deleteSchemaForNpConflictTest(cellName, boxName, colName, enreplacedyTypeName, navPropName);
    }
}

9 Source : ProcessDefinitionResourceTest.java
with Apache License 2.0
from flowable

/**
 * Test suspending already suspended process definition. POST repository/process-definitions/{processDefinitionId}
 */
@Test
@Deployment(resources = { "org/flowable/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testSuspendAlreadySuspendedProcessDefinition() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    repositoryService.suspendProcessDefinitionById(processDefinition.getId());
    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    replacedertThat(processDefinition.isSuspended()).isTrue();
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "suspend");
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEnreplacedy(new StringEnreplacedy(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
    closeResponse(response);
}

8 Source : RelationDeleteTest.java
with Apache License 2.0
from personium

/**
 * ExtRoleとLinkされているRelationを削除するとresponseが409であること.
 */
@SuppressWarnings("unchecked")
@Test
public final void ExtRoleとLinkされているRelationを削除するとresponseが409であること() {
    String boxName = "box1";
    String relationName = "boxLinkrelation";
    String extRoleName = UrlUtils.roleResource(cellName, "__", "relationLinkextRole");
    JSONObject relationBody = new JSONObject();
    relationBody.put("Name", relationName);
    relationBody.put("_Box.Name", boxName);
    JSONObject extRoleBody = new JSONObject();
    extRoleBody.put("ExtRole", extRoleName);
    extRoleBody.put("_Relation.Name", relationName);
    extRoleBody.put("_Relation._Box.Name", boxName);
    try {
        // Relationの作成
        RelationUtils.create(cellName, MASTER_TOKEN_NAME, relationBody, HttpStatus.SC_CREATED);
        // 上のRelationと結びつくExtRole作成
        ExtRoleUtils.create(MASTER_TOKEN_NAME, cellName, extRoleBody, HttpStatus.SC_CREATED);
        // Relationの削除(結びつくextRoleがあるため、409)
        RelationUtils.delete(cellName, MASTER_TOKEN_NAME, relationName, boxName, HttpStatus.SC_CONFLICT);
        // 結びつくextRoleの削除
        ExtRoleUtils.delete(cellName, extRoleName, relationName, boxName, MASTER_TOKEN_NAME, HttpStatus.SC_NO_CONTENT);
        // Relationの削除(結びつくextRoleが存在しないため、204)
        RelationUtils.delete(cellName, MASTER_TOKEN_NAME, relationName, boxName, HttpStatus.SC_NO_CONTENT);
    } finally {
        // 結びつくextRoleの削除
        ExtRoleUtils.delete(cellName, extRoleName, relationName, boxName, MASTER_TOKEN_NAME, -1);
        // Relationの削除
        RelationUtils.delete(cellName, MASTER_TOKEN_NAME, relationName, boxName, -1);
    }
}

See More Examples