/** serviceコレクション配下のリソースのMOVEで405エラーとなること. */
  @Test
  public final void serviceコレクション配下のリソースのMOVEで405エラーとなること() {
    final String srcCol = "srcColName";
    final String destColName = "destColName";
    final String destUrl = UrlUtils.box(CELL_NAME, BOX_NAME, destColName);
    try {
      // 事前準備
      DavResourceUtils.createServiceCollection(
          AbstractCase.BEARER_MASTER_TOKEN, HttpStatus.SC_CREATED, CELL_NAME, BOX_NAME, srcCol);

      // 移動
      // このリソースはサービス実行用であるが、MOVEメソッドは実行対象外としているため405が返却される。
      String srcUrl = UrlUtils.box(CELL_NAME, BOX_NAME, srcCol, "dummyResource");
      DcRequest req = DcRequest.move(srcUrl);
      req.header(HttpHeaders.AUTHORIZATION, AbstractCase.BEARER_MASTER_TOKEN);
      req.header(HttpHeaders.DESTINATION, destUrl);
      req.header(HttpHeaders.OVERWRITE, "F");
      DcResponse response = AbstractCase.request(req);

      assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SC_METHOD_NOT_ALLOWED);
      DcCoreException expectedException = DcCoreException.Misc.METHOD_NOT_ALLOWED;
      ODataCommon.checkErrorResponseBody(
          response, expectedException.getCode(), expectedException.getMessage());
    } finally {
      DavResourceUtils.deleteCollection(CELL_NAME, BOX_NAME, srcCol, TOKEN, -1);
    }
  }
Example #2
0
  /** 小文字Cell名で作成したCellに対してCellレベルAPIが利用できること. */
  @Test
  public final void 小文字Cell名で作成したCellに対してCellレベルAPIが利用できること() {
    // 小文字Cell名のCellを作成
    DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
    cellNormal(req, cellNameLower);

    // 小文字Cell名を指定してBoxの一覧取得を実行
    req = DcRequest.get(UrlUtils.cellCtl(cellNameLower, "Box"));
    req.header(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
    DcResponse response = request(req);

    // 200になることを確認
    assertEquals(HttpStatus.SC_OK, response.getStatusCode());
  }
  /** UserDataに完全一致検索クエリのキーを真偽値falseで指定して対象のデータのみ取得できること. */
  @Test
  public final void UserDataに完全一致検索クエリのキーを真偽値falseで指定して対象のデータのみ取得できること() {
    String entityTypeName = "boolFilterTest";
    try {
      // Boolean検索のテスト用データを作成する
      createTestData(entityTypeName);

      // 取得対象のデータに対する検索を実施する
      // ユーザデータの一覧取得
      String searchRequestUrl =
          UrlUtils.userData(cellName, boxName, colName, entityTypeName)
              + "?$filter=bool+eq+false&$inlinecount=allpages";
      DcRequest req = DcRequest.get(searchRequestUrl);
      req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
      req.header(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
      DcResponse searchResponse = request(req);
      assertEquals(HttpStatus.SC_OK, searchResponse.getStatusCode());
      JSONObject responseBody = searchResponse.bodyAsJson();

      // ヒットしたデータが1件であることを確認する
      String count = (String) ((JSONObject) responseBody.get("d")).get("__count");
      assertEquals("1", count);

      // 期待したデータが取得できたことを確認する
      JSONArray results = (JSONArray) ((JSONObject) responseBody.get("d")).get("results");
      assertEquals("boolFalse", (String) ((JSONObject) results.get(0)).get("__id"));
      assertEquals(false, (Boolean) ((JSONObject) results.get(0)).get("bool"));
    } finally {
      deleteTestData(entityTypeName);
    }
  }
Example #4
0
  /**
   * Propertyを登録する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param propertyName Property名
   * @param type PropertyのType項目
   * @param nullable PropertyのNullable項目
   * @param defaultValue PropertyのDefaultValue項目
   * @param collectionKind PropertyのcollectionKind項目
   * @param isKey PropertyのisKey項目
   * @param uniqueKey PropertyのUniqueKey項目
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static DcResponse create(
      String token,
      String cell,
      String box,
      String collection,
      String entityTypeName,
      String propertyName,
      String type,
      boolean nullable,
      Object defaultValue,
      String collectionKind,
      boolean isKey,
      String uniqueKey,
      int code) {

    String url = UrlUtils.property(cell, box, collection, null, null);
    DcRequest req = DcRequest.post(url);
    req.header(HttpHeaders.AUTHORIZATION, token);
    req.addJsonBody(PROPERTY_NAME_KEY, propertyName);
    req.addJsonBody(PROPERTY_ENTITYTYPE_NAME_KEY, entityTypeName);
    req.addJsonBody(PROPERTY_TYPE_KEY, type);
    req.addJsonBody(PROPERTY_NULLABLE_KEY, nullable);
    req.addJsonBody(PROPERTY_DEFAULT_VALUE_KEY, defaultValue);
    req.addJsonBody(PROPERTY_COLLECTION_KIND_KEY, collectionKind);
    req.addJsonBody(PROPERTY_IS_KEY_KEY, isKey);
    req.addJsonBody(PROPERTY_UNIQUE_KEY_KEY, uniqueKey);

    // リクエスト実行
    DcResponse response = AbstractCase.request(req);
    if (code != -1) {
      assertEquals(code, response.getStatusCode());
    }
    return response;
  }
Example #5
0
  /** Boxインストールで作成する場合のコレクション配下のファイル最大数チェックのテスト. */
  @Test
  public final void Boxインストールで作成する場合のコレクション配下のファイル最大数チェックのテスト() {
    // 本テストでは子要素の最大数:20 コレクションの最大階層数:5の設定となっていることを前提とし、
    // WebDavコレクションの子要素数21(全てWebDavファイル)のBarファイルを登録して、エラーとなることを確認する。
    final String barFilePath = "/V1_1_2_bar_webdav_file_count_error.bar";
    String cellName = "collectionLimitCell";
    String box = INSTALL_TARGET;

    try {
      // テスト用Cellの作成
      CellUtils.create(cellName, TOKEN, HttpStatus.SC_CREATED);

      TResponse res = null;
      File barFile = new File(RESOURCE_PATH + barFilePath);
      byte[] body = BarInstallTestUtils.readBarFile(barFile);
      Map<String, String> headers = new LinkedHashMap<String, String>();
      headers.put(HttpHeaders.CONTENT_TYPE, REQ_CONTENT_TYPE);
      headers.put(HttpHeaders.CONTENT_LENGTH, String.valueOf(body.length));

      res = BarInstallTestUtils.request(REQUEST_NORM_FILE, cellName, box, headers, body);
      res.statusCode(HttpStatus.SC_ACCEPTED);
      String location = res.getHeader(HttpHeaders.LOCATION);
      String expected = UrlUtils.cellRoot(cellName) + box;
      assertEquals(expected, location);

      BarInstallTestUtils.assertBarInstallStatus(
          location, DEFAULT_SCHEMA_URL, ProgressInfo.STATUS.FAILED);
    } finally {
      // Cellの再帰的削除
      Setup.cellBulkDeletion(cellName);
    }
  }
  /** ユーザスキーマメタデータのMOVEで405エラーとなること. */
  @Test
  public final void ユーザスキーマメタデータのMOVEで405エラーとなること() {
    final String destColName = "destColName";
    final String destUrl = UrlUtils.box(CELL_NAME, BOX_NAME, destColName);
    // 移動
    String srcUrl = UrlUtils.box(CELL_NAME, BOX_NAME, Setup.TEST_ODATA, "$metadata/$metadata");
    DcRequest req = DcRequest.move(srcUrl);
    req.header(HttpHeaders.AUTHORIZATION, AbstractCase.BEARER_MASTER_TOKEN);
    req.header(HttpHeaders.DESTINATION, destUrl);
    req.header(HttpHeaders.OVERWRITE, "F");
    DcResponse response = AbstractCase.request(req);

    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SC_METHOD_NOT_ALLOWED);
    DcCoreException expectedException = DcCoreException.Misc.METHOD_NOT_ALLOWED;
    ODataCommon.checkErrorResponseBody(
        response, expectedException.getCode(), expectedException.getMessage());
  }
Example #7
0
 /** 登録したCellを削除後すぐに再登録するテスト. */
 @Test
 public final void 登録したCellを削除後すぐに再登録するテスト() {
   // Cellを作成
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   DcResponse res = cellNormalResponse(req, cellNameLower);
   // Cell削除
   cellDelete(res);
   // Cellを再作成
   cellNormal(req, cellNameLower);
 }
Example #8
0
  /**
   * Propertyを取得する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param query クエリ
   * @return レスポンス
   */
  public static DcResponse list(
      String token, String cell, String box, String collection, String query) {
    String locationUrl = UrlUtils.property(cell, box, collection, null, null);
    if (null != query) {
      locationUrl += query;
    }

    // Property取得
    DcRequest req = DcRequest.get(locationUrl);
    req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
    req.header(HttpHeaders.AUTHORIZATION, OAuth2Helper.Scheme.BEARER + " " + token);
    return AbstractCase.request(req);
  }
 /** UserDataに完全一致検索クエリのキーに文字列hogeを指定した場合ステータスコード400が返却されること. */
 @Test
 public final void UserDataに完全一致検索クエリのキーに文字列hogeを指定した場合ステータスコード400が返却されること() {
   // 取得対象のデータに対する検索を実施する
   // ユーザデータの一覧取得
   String entityTypeName = "SalesDetail";
   String searchRequestUrl =
       UrlUtils.userData(cellName, boxName, colName, entityTypeName)
           + "?$filter=truth+eq+%27hoge%27&$inlinecount=allpages";
   DcRequest req = DcRequest.get(searchRequestUrl);
   req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
   req.header(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
   DcResponse searchResponse = request(req);
   assertEquals(HttpStatus.SC_BAD_REQUEST, searchResponse.getStatusCode());
 }
Example #10
0
  /**
   * Propertyを取得する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param propertyName Property名
   * @param entityTypeName EntityType名
   * @return レスポンス
   */
  public static DcResponse get(
      String token,
      String cell,
      String box,
      String collection,
      String propertyName,
      String entityTypeName) {
    String locationUrl = UrlUtils.property(cell, box, collection, propertyName, entityTypeName);

    // Property取得
    DcRequest req = DcRequest.get(locationUrl);
    req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
    req.header(HttpHeaders.AUTHORIZATION, OAuth2Helper.Scheme.BEARER + " " + token);
    return AbstractCase.request(req);
  }
Example #11
0
  /**
   * Propertyを更新する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param srcPropertyName 更新前Property名
   * @param srcEntityTypeName 更新前EntityType名
   * @param body リクエストボディ
   * @return レスポンス
   */
  public static DcResponse update(
      String token,
      String cell,
      String box,
      String collection,
      String srcPropertyName,
      String srcEntityTypeName,
      JSONObject body) {

    // リクエストパラメータ設定
    DcRequest req =
        DcRequest.put(UrlUtils.property(cell, box, collection, srcPropertyName, srcEntityTypeName));
    req.header(HttpHeaders.AUTHORIZATION, OAuth2Helper.Scheme.BEARER + " " + token);
    req.header(HttpHeaders.IF_MATCH, "*");
    req.addStringBody(body.toJSONString());

    // リクエスト実行
    return AbstractCase.request(req);
  }
Example #12
0
  /**
   * Propertyを削除する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param propertyName Property名
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static DcResponse delete(
      String token,
      String cell,
      String box,
      String collection,
      String entityTypeName,
      String propertyName,
      int code) {

    String url = UrlUtils.property(cell, box, collection, propertyName, entityTypeName);
    DcRequest req = DcRequest.delete(url);
    req.header(HttpHeaders.AUTHORIZATION, token);

    // リクエスト実行
    DcResponse response = AbstractCase.request(req);
    if (code != -1) {
      assertEquals(code, response.getStatusCode());
    }
    return response;
  }
Example #13
0
/** PropertyUtils. */
public class PropertyUtils {
  /** コンストラクタ. */
  private PropertyUtils() {}

  /** Property NameKey名. */
  public static final String PROPERTY_NAME_KEY = Property.P_NAME.getName().toString();

  /** Property _EntityTypeKey名. */
  public static final String PROPERTY_ENTITYTYPE_NAME_KEY =
      Property.P_ENTITYTYPE_NAME.getName().toString();

  /** Property TypeKey名. */
  public static final String PROPERTY_TYPE_KEY = Property.P_TYPE.getName().toString();

  /** Property NullableKey名. */
  public static final String PROPERTY_NULLABLE_KEY = Property.P_NULLABLE.getName().toString();

  /** Property DefaultValueKey名. */
  public static final String PROPERTY_DEFAULT_VALUE_KEY =
      Property.P_DEFAULT_VALUE.getName().toString();

  /** Property CollectionKindKey名. */
  public static final String PROPERTY_COLLECTION_KIND_KEY =
      Property.P_COLLECTION_KIND.getName().toString();

  /** Property IsKeyKey名. */
  public static final String PROPERTY_IS_KEY_KEY = Property.P_IS_KEY.getName().toString();

  /** Property UniqueKeyKey名. */
  public static final String PROPERTY_UNIQUE_KEY_KEY = Property.P_UNIQUE_KEY.getName().toString();

  /** Property isDeclared名. */
  public static final String PROPERTY_IS_DECLARED_KEY = Property.P_IS_DECLARED.getName().toString();

  /** PropertyリソースURL. */
  public static final String REQUEST_URL =
      UrlUtils.property(Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA, null, null);

  /** 名前空間. */
  public static final String NAMESPACE =
      Common.EDM_NS_ODATA_SVC_SCHEMA + "." + Property.EDM_TYPE_NAME;

  /**
   * PropertyをEntityTypeからのNP経由で登録する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param propertyName Property名
   * @param type PropertyのType項目
   * @param nullable PropertyのNullable項目
   * @param defaultValue PropertyのDefaultValue項目
   * @param collectionKind PropertyのcollectionKind項目
   * @param isKey PropertyのisKey項目
   * @param uniqueKey PropertyのUniqueKey項目
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  @SuppressWarnings("unchecked")
  public static TResponse createViaPropertyNP(
      String token,
      String cell,
      String box,
      String collection,
      String entityTypeName,
      String propertyName,
      String type,
      Boolean nullable,
      String defaultValue,
      String collectionKind,
      Boolean isKey,
      String uniqueKey,
      int code) {

    // リクエストボディの組み立て
    JSONObject body = new JSONObject();
    body.put("Name", propertyName);
    body.put("_EntityType.Name", entityTypeName);
    body.put("Type", type);
    body.put("Nullable", nullable);
    body.put("DefaultValue", defaultValue);
    body.put("CollectionKind", collectionKind);
    body.put("IsKey", isKey);
    body.put("UniqueKey", uniqueKey);

    TResponse res =
        Http.request("box/odatacol/schema/createViaNP.txt")
            .with("cell", cell)
            .with("box", box)
            .with("collection", collection)
            .with("accept", MediaType.APPLICATION_JSON)
            .with("contentType", MediaType.APPLICATION_JSON)
            .with("token", DcCoreConfig.getMasterToken())
            .with("entityType", "EntityType")
            .with("id", entityTypeName)
            .with("navPropName", "_Property")
            .with("body", body.toJSONString())
            .returns()
            .statusCode(code)
            .debug();
    return res;
  }

  /**
   * PropertyをEntityTypeからのNP経由で一覧取得する.
   *
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static TResponse listViaPropertyNP(
      String cell, String box, String collection, String entityTypeName, int code) {

    TResponse res =
        Http.request("box/odatacol/schema/listViaNP.txt")
            .with("cell", cell)
            .with("box", box)
            .with("collection", collection)
            .with("accept", MediaType.APPLICATION_JSON)
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("entityType", "EntityType")
            .with("id", entityTypeName)
            .with("navPropName", "_Property")
            .returns()
            .statusCode(code)
            .debug();
    return res;
  }

  /**
   * Propertyを登録する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param propertyName Property名
   * @param type PropertyのType項目
   * @param nullable PropertyのNullable項目
   * @param defaultValue PropertyのDefaultValue項目
   * @param collectionKind PropertyのcollectionKind項目
   * @param isKey PropertyのisKey項目
   * @param uniqueKey PropertyのUniqueKey項目
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static DcResponse create(
      String token,
      String cell,
      String box,
      String collection,
      String entityTypeName,
      String propertyName,
      String type,
      boolean nullable,
      Object defaultValue,
      String collectionKind,
      boolean isKey,
      String uniqueKey,
      int code) {

    String url = UrlUtils.property(cell, box, collection, null, null);
    DcRequest req = DcRequest.post(url);
    req.header(HttpHeaders.AUTHORIZATION, token);
    req.addJsonBody(PROPERTY_NAME_KEY, propertyName);
    req.addJsonBody(PROPERTY_ENTITYTYPE_NAME_KEY, entityTypeName);
    req.addJsonBody(PROPERTY_TYPE_KEY, type);
    req.addJsonBody(PROPERTY_NULLABLE_KEY, nullable);
    req.addJsonBody(PROPERTY_DEFAULT_VALUE_KEY, defaultValue);
    req.addJsonBody(PROPERTY_COLLECTION_KIND_KEY, collectionKind);
    req.addJsonBody(PROPERTY_IS_KEY_KEY, isKey);
    req.addJsonBody(PROPERTY_UNIQUE_KEY_KEY, uniqueKey);

    // リクエスト実行
    DcResponse response = AbstractCase.request(req);
    if (code != -1) {
      assertEquals(code, response.getStatusCode());
    }
    return response;
  }

  /**
   * PropertyのLocation URLを作成する.
   *
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param propertyName Property名
   * @param entityTypeName EntityType名
   * @return Location URL
   */
  public static String composeLocationUrl(
      String cell, String box, String collection, String propertyName, String entityTypeName) {
    return UrlUtils.property(cell, box, collection, propertyName, entityTypeName);
  }

  /**
   * Propertyを取得する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param propertyName Property名
   * @param entityTypeName EntityType名
   * @return レスポンス
   */
  public static DcResponse get(
      String token,
      String cell,
      String box,
      String collection,
      String propertyName,
      String entityTypeName) {
    String locationUrl = UrlUtils.property(cell, box, collection, propertyName, entityTypeName);

    // Property取得
    DcRequest req = DcRequest.get(locationUrl);
    req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
    req.header(HttpHeaders.AUTHORIZATION, OAuth2Helper.Scheme.BEARER + " " + token);
    return AbstractCase.request(req);
  }

  /**
   * Propertyを取得する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @return レスポンス
   */
  public static DcResponse list(String token, String cell, String box, String collection) {
    return list(token, cell, box, collection, null);
  }

  /**
   * Propertyを取得する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param query クエリ
   * @return レスポンス
   */
  public static DcResponse list(
      String token, String cell, String box, String collection, String query) {
    String locationUrl = UrlUtils.property(cell, box, collection, null, null);
    if (null != query) {
      locationUrl += query;
    }

    // Property取得
    DcRequest req = DcRequest.get(locationUrl);
    req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
    req.header(HttpHeaders.AUTHORIZATION, OAuth2Helper.Scheme.BEARER + " " + token);
    return AbstractCase.request(req);
  }

  /**
   * Propertyを更新する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param srcPropertyName 更新前Property名
   * @param srcEntityTypeName 更新前EntityType名
   * @param propertyName リクエストに指定するProperty名
   * @param entityTypeName リクエストに指定するEntityType名
   * @param type PropertyのType項目
   * @param nullable PropertyのNullable項目
   * @param defaultValue PropertyのDefaultValue項目
   * @param collectionKind PropertyのcollectionKind項目
   * @param isKey PropertyのisKey項目
   * @param uniqueKey PropertyのUniqueKey項目
   * @return レスポンス
   */
  @SuppressWarnings("unchecked")
  public static DcResponse update(
      String token,
      String cell,
      String box,
      String collection,
      String srcPropertyName,
      String srcEntityTypeName,
      String propertyName,
      String entityTypeName,
      String type,
      Boolean nullable,
      Object defaultValue,
      String collectionKind,
      Boolean isKey,
      String uniqueKey) {

    // リクエストボディの組み立て
    JSONObject body = new JSONObject();
    body.put("Name", propertyName);
    body.put("_EntityType.Name", entityTypeName);
    body.put("Type", type);
    body.put("Nullable", nullable);
    body.put("DefaultValue", defaultValue);
    body.put("CollectionKind", collectionKind);
    body.put("IsKey", isKey);
    body.put("UniqueKey", uniqueKey);

    return update(token, cell, box, collection, srcPropertyName, srcEntityTypeName, body);
  }

  /**
   * Propertyを更新する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param srcPropertyName 更新前Property名
   * @param srcEntityTypeName 更新前EntityType名
   * @param body リクエストボディ
   * @return レスポンス
   */
  public static DcResponse update(
      String token,
      String cell,
      String box,
      String collection,
      String srcPropertyName,
      String srcEntityTypeName,
      JSONObject body) {

    // リクエストパラメータ設定
    DcRequest req =
        DcRequest.put(UrlUtils.property(cell, box, collection, srcPropertyName, srcEntityTypeName));
    req.header(HttpHeaders.AUTHORIZATION, OAuth2Helper.Scheme.BEARER + " " + token);
    req.header(HttpHeaders.IF_MATCH, "*");
    req.addStringBody(body.toJSONString());

    // リクエスト実行
    return AbstractCase.request(req);
  }

  /**
   * Propertyを削除する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param propertyName Property名
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static DcResponse delete(
      String token,
      String cell,
      String box,
      String collection,
      String entityTypeName,
      String propertyName,
      int code) {

    String url = UrlUtils.property(cell, box, collection, propertyName, entityTypeName);
    DcRequest req = DcRequest.delete(url);
    req.header(HttpHeaders.AUTHORIZATION, token);

    // リクエスト実行
    DcResponse response = AbstractCase.request(req);
    if (code != -1) {
      assertEquals(code, response.getStatusCode());
    }
    return response;
  }

  /**
   * EntityTypeからのNP経由でPropertyを一覧取得する.
   *
   * @param token トークン
   * @param cell セル名
   * @param box ボックス名
   * @param collection コレクション名
   * @param entityTypeName EntityType名
   * @param code 期待するレスポンスコード
   * @return レスポンス
   */
  public static TResponse listLinks(
      String token, String cell, String box, String collection, String entityTypeName, int code) {

    String path = String.format("\\$metadata/%s('%s')", EntityType.EDM_TYPE_NAME, entityTypeName);
    return Http.request("box/odatacol/list-link.txt")
        .with("cellPath", cell)
        .with("boxPath", box)
        .with("colPath", collection)
        .with("srcPath", path)
        .with("trgPath", Property.EDM_TYPE_NAME)
        .with("token", token)
        .with("accept", MediaType.APPLICATION_JSON)
        .returns()
        .statusCode(code)
        .debug();
  }
}
Example #14
0
 /**
  * PropertyのLocation URLを作成する.
  *
  * @param cell セル名
  * @param box ボックス名
  * @param collection コレクション名
  * @param propertyName Property名
  * @param entityTypeName EntityType名
  * @return Location URL
  */
 public static String composeLocationUrl(
     String cell, String box, String collection, String propertyName, String entityTypeName) {
   return UrlUtils.property(cell, box, collection, propertyName, entityTypeName);
 }
Example #15
0
 /** Cell作成のリクエストボディに管理情報[__updated]が指定された場合に400が返却されること. */
 @Test
 public final void Cell作成のリクエストボディに管理情報__updatedが指定された場合に400が返却されること() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorBodyDateCtl(req, UPDATED);
 }
Example #16
0
 /** Cellの作成の認証ヘッダ無しのテスト. */
 @Test
 public final void Cellの作成の認証ヘッダ無しのテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorAuthNone(req);
 }
  /** barファイルインストール後イベントログを取得して正常終了すること. */
  @Test
  public final void barファイルインストール後イベントログを取得して正常終了すること() {
    try {
      // CELL作成
      CellUtils.create(UNIT_USER_CELL, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_CREATED);

      // Barインストール実施
      String reqCell = UNIT_USER_CELL;
      String reqPath = INSTALL_TARGET;

      TResponse res = null;
      File barFile = new File(RESOURCE_PATH + BAR_FILE_MINIMUM);
      byte[] body = BarInstallTestUtils.readBarFile(barFile);
      Map<String, String> headers = new LinkedHashMap<String, String>();
      headers.put(HttpHeaders.CONTENT_TYPE, REQ_CONTENT_TYPE);
      headers.put(HttpHeaders.CONTENT_LENGTH, String.valueOf(body.length));

      res = BarInstallTestUtils.request(REQUEST_NORM_FILE, reqCell, reqPath, headers, body);
      res.statusCode(HttpStatus.SC_ACCEPTED);
      String location = res.getHeader(HttpHeaders.LOCATION);
      String expected = UrlUtils.cellRoot(reqCell) + reqPath;
      assertEquals(expected, location);

      BarInstallTestUtils.assertBarInstallStatus(
          location, DEFAULT_SCHEMA_URL, ProgressInfo.STATUS.COMPLETED);

      // イベント取得
      TResponse response =
          Http.request("cell/log-get.txt")
              .with("METHOD", HttpMethod.GET)
              .with("token", AbstractCase.MASTER_TOKEN_NAME)
              .with("cellPath", UNIT_USER_CELL)
              .with("collection", CURRENT_COLLECTION)
              .with("fileName", DEFAULT_LOG)
              .with("ifNoneMatch", "*")
              .returns();
      response.debug();

      // レスポンスの解析
      List<String[]> lines = BarInstallTestUtils.getListedBody(response.getBody());
      int count = 0;
      for (String[] line : lines) {
        if (line[6].equals(WebDAVMethod.MKCOL.toString())) {
          assertEquals("202", line[8].trim());
          break;
        }
        count++;
      }
      assertTrue(count < lines.size());
      lines.remove(count);

      int index = 0;
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1000",
          UrlUtils.getBaseUrl() + "/UnitUserCell/installBox",
          "Bar installation started.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1001",
          "bar/00_meta/00_manifest.json",
          "Installation started.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1003",
          "bar/00_meta/00_manifest.json",
          "Installation completed.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1001",
          "bar/00_meta/90_rootprops.xml",
          "Installation started.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-1003",
          "bar/00_meta/90_rootprops.xml",
          "Installation completed.",
          index++);
      checkResponseLog(
          lines,
          "[INFO ]",
          "server",
          "PL-BI-0000",
          UrlUtils.getBaseUrl() + "/UnitUserCell/installBox",
          "Bar installation completed.",
          index++);
      response.statusCode(HttpStatus.SC_OK);
    } finally {
      cleanup();
      // CELL削除
      CellUtils.delete(AbstractCase.MASTER_TOKEN_NAME, UNIT_USER_CELL);
    }
  }
Example #18
0
 /** Cell作成のリクエストボディに管理情報[__metadata]が指定された場合に400が返却されること. */
 @Test
 public final void Cell作成のリクエストボディに管理情報__metadataが指定された場合に400が返却されること() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorBodyMetadataCtl(req, METADATA);
 }
Example #19
0
 /** Cellの作成のNameが129文字のパターンのテスト. */
 @Test
 public final void Cellの作成のNameが129文字のパターンのテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorName129(req);
 }
Example #20
0
 /** Cellの作成で大文字のCell名を登録した後に小文字で同じCell名を登録した場合、201となることを確認するテスト. */
 @Test
 public final void Cellの作成で大文字のCell名を登録した後に小文字で同じCell名を登録した場合_201となることを確認() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellCreateResCheck(
       req, HttpMethod.POST, UrlUtils.unitCtl(Cell.EDM_TYPE_NAME), cellNameUpper, cellNameLower);
 }
Example #21
0
 /** Cellの作成で大文字のCell名を登録した後に同じ大文字のCell名を登録した場合、409となることを確認するテスト. */
 @Test
 public final void Cellの作成で大文字のCell名を登録した後に同じ大文字のCell名を登録した場合_409となることを確認() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellConflict(req, cellNameUpper);
 }
Example #22
0
 /** Cellの作成の不正なメソッドのテスト. */
 @Test
 public final void Cellの作成の不正なメソッドのテスト() {
   DcRequest req = DcRequest.delete(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorInvalidMethod(req, cellNameLower);
 }
Example #23
0
 /** Cellの作成の不正な認証ヘッダのテスト. */
 @Test
 public final void Cellの作成の不正な認証ヘッダのテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorAuthInvalid(req);
 }
Example #24
0
 /** Cellの作成のNameが[__ctl]の場合に400が返却されること. */
 @Test
 public final void Cellの作成のNameが__ctlの場合に400が返却されること() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorNameUnderbaerCtl(req);
 }
Example #25
0
 /** Cellの作成のリクエストボディに不正なフィールド名を指定したパターンのテスト. */
 @Test
 public final void Cellの作成のリクエストボディに不正なフィールド名を指定したパターンのテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorInvalidField(req, cellNameLower);
 }
Example #26
0
 /** Cellの作成のリクエストボディが無いパターンのテスト. */
 @Test
 public final void Cellの作成のリクエストボディが無いパターンのテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorEmptyBody(req);
 }
Example #27
0
 /** Cellの作成のXMLフォーマットエラーのテスト. */
 @Test
 public final void Cellの作成のXMLフォーマットエラーのテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorInvalidXml(req, cellNameLower);
 }
Example #28
0
 /** Cellの作成の正常系のテスト. */
 @Test
 public final void Cellの作成の正常系のテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellNormal(req, cellNameLower);
 }
Example #29
0
 /** Cellの作成のNameが半角英数と"-","_"以外のパターンのテスト. */
 @Test
 public final void Cellの作成のNameが不正な値のパターンのテスト() {
   DcRequest req = DcRequest.post(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME));
   cellErrorNameCharacter(req);
 }