private SpiderDataGroup createRecordInfo() {
   SpiderDataGroup recordInfo = SpiderDataGroup.withNameInData("recordInfo");
   recordInfo.addChild(SpiderDataAtomic.withNameInDataAndValue("id", "place:0001"));
   recordInfo.addChild(SpiderDataAtomic.withNameInDataAndValue("type", "place"));
   recordInfo.addChild(SpiderDataAtomic.withNameInDataAndValue("createdBy", "userId"));
   return recordInfo;
 }
Example #2
0
  private void addResourceInfoToMetadataRecord(String fileName, long fileSize) {
    SpiderDataGroup resourceInfo = SpiderDataGroup.withNameInData(RESOURCE_INFO);
    spiderRecordRead.addChild(resourceInfo);

    SpiderDataGroup master = SpiderDataGroup.withNameInData("master");
    resourceInfo.addChild(master);

    SpiderDataAtomic streamId2 = SpiderDataAtomic.withNameInDataAndValue("streamId", streamId);
    master.addChild(streamId2);

    SpiderDataAtomic uploadedFileName =
        SpiderDataAtomic.withNameInDataAndValue("filename", fileName);
    master.addChild(uploadedFileName);

    SpiderDataAtomic size =
        SpiderDataAtomic.withNameInDataAndValue("filesize", String.valueOf(fileSize));
    master.addChild(size);

    SpiderDataAtomic mimeType =
        SpiderDataAtomic.withNameInDataAndValue("mimeType", "application/octet-stream");
    master.addChild(mimeType);
  }
  @Test
  public void testToRestWithGroup() {
    SpiderDataGroup spiderDataGroup = SpiderDataGroup.withNameInData("groupId");
    spiderDataGroup.addChild(createRecordInfo());
    SpiderDataList spiderDataList = SpiderDataList.withContainDataOfType("place");
    spiderDataList.addData(spiderDataGroup);
    spiderDataList.setTotalNo("10");
    spiderDataList.setFromNo("0");
    spiderDataList.setToNo("1");

    DataListSpiderToRestConverter converter =
        DataListSpiderToRestConverter.fromSpiderDataListWithBaseURL(spiderDataList, baseURL);

    RestDataList recordList = converter.toRest();

    RestDataGroup restDataGroup = ((RestDataGroup) recordList.getDataList().get(0));

    assertEquals(restDataGroup.getNameInData(), "groupId");
  }