コード例 #1
0
  //	Paging
  @Test
  public void testPageListOfAssets() throws Exception {

    // add 3 stories
    Asset storyAsset = createDisposableStory();
    storyAsset.setAttributeValue(nameDef, "Paging Test - Story1");
    storyAsset.setAttributeValue(scopeDef, APIClientLegacyIntegrationTestSuiteIT.get_projectId());
    services.save(storyAsset);
    storyAsset = createDisposableStory();
    storyAsset.setAttributeValue(nameDef, "Paging Test - Story2");
    storyAsset.setAttributeValue(scopeDef, APIClientLegacyIntegrationTestSuiteIT.get_projectId());
    services.save(storyAsset);
    storyAsset = createDisposableStory();
    storyAsset.setAttributeValue(nameDef, "Paging Test - Story3");
    storyAsset.setAttributeValue(scopeDef, APIClientLegacyIntegrationTestSuiteIT.get_projectId());
    services.save(storyAsset);

    Query query = new Query(storyType);
    IAttributeDefinition nameAttribute = storyType.getAttributeDefinition("Name");
    IAttributeDefinition estimateAttribute = storyType.getAttributeDefinition("Estimate");
    query.getSelection().add(nameAttribute);
    query.getSelection().add(estimateAttribute);
    QueryResult result = services.retrieve(query);

    Assert.assertTrue(result.getAssets().length > 2);

    query.getPaging().setPageSize(2);
    query.getPaging().setStart(0);
    result = services.retrieve(query);

    Assert.assertTrue(result.getAssets().length == 2);
  }
コード例 #2
0
  // asof
  @Test
  @Ignore
  public void testAsof() throws Exception {
    Asset storyAsset = createDisposableStory();
    storyAsset.setAttributeValue(nameDef, "Test Asof");
    storyAsset.setAttributeValue(scopeDef, APIClientLegacyIntegrationTestSuiteIT.get_projectId());
    services.save(storyAsset);

    IAssetType storyType = metaModel.getAssetType("Story");
    Query query = new Query(storyType, true);
    IAttributeDefinition nameAttribute = storyType.getAttributeDefinition("Name");
    IAttributeDefinition createDateAttribute = storyType.getAttributeDefinition("CreateDate");

    query.getSelection().add(nameAttribute);
    query.getSelection().add(createDateAttribute);
    AttributeSelection selection = new AttributeSelection();
    selection.add(nameAttribute);
    query.setFind(new QueryFind("Test Asof", selection));
    Date date = (Date) Calendar.getInstance().getTime();
    query.setAsOf(date);
    QueryResult result = services.retrieve(query);

    //	Assert.assertNotNull(result);

    Assert.assertEquals(
        "Test Asof", result.getAssets()[0].getAttribute(nameAttribute).getValue().toString());
  }
コード例 #3
0
  // Sort query
  @Test
  public void testSortStories() throws Exception {

    // add 3 stories
    Asset storyAsset = createDisposableStory();
    storyAsset.setAttributeValue(nameDef, "MM-Story");
    storyAsset.setAttributeValue(scopeDef, APIClientLegacyIntegrationTestSuiteIT.get_projectId());
    services.save(storyAsset);
    storyAsset = createDisposableStory();
    storyAsset.setAttributeValue(nameDef, "AA-Story");
    storyAsset.setAttributeValue(scopeDef, APIClientLegacyIntegrationTestSuiteIT.get_projectId());
    services.save(storyAsset);
    storyAsset = createDisposableStory();
    storyAsset.setAttributeValue(nameDef, "HH-Story");
    storyAsset.setAttributeValue(scopeDef, APIClientLegacyIntegrationTestSuiteIT.get_projectId());
    services.save(storyAsset);

    IAssetType storyType = metaModel.getAssetType("Story");
    Query query = new Query(storyType);
    IAttributeDefinition nameAttribute = storyType.getAttributeDefinition("Name");
    query.getSelection().add(nameAttribute);
    query.getOrderBy().minorSort(nameAttribute, Order.Ascending);

    QueryResult result = services.retrieve(query);

    Asset first_story = result.getAssets()[0];

    Assert.assertEquals("AA-Story", first_story.getAttribute(nameAttribute).getValue().toString());
  }
コード例 #4
0
  // Query for single assets
  @Test
  public void testQuerySingleAsset() throws Exception {

    Oid memberId = Oid.fromToken("Member:20", metaModel);
    Query query = new Query(memberId);
    IAttributeDefinition nameAttribute = metaModel.getAttributeDefinition("Member.Username");
    query.getSelection().add(nameAttribute);
    QueryResult result = services.retrieve(query);

    Assert.assertNotNull(result.getAssets());

    Assert.assertEquals("1 asset", 1, result.getAssets().length);
  }
コード例 #5
0
  // Query for multiple assets
  @Test
  public void testQueryMultipleAsset() throws Exception {

    Query query = new Query(storyType);
    IAttributeDefinition nameAttribute = storyType.getAttributeDefinition("Name");
    IAttributeDefinition estimateAttribute = storyType.getAttributeDefinition("Estimate");
    query.getSelection().add(nameAttribute);
    query.getSelection().add(estimateAttribute);
    QueryResult result = services.retrieve(query);

    Assert.assertNotNull(result.getAssets());

    Assert.assertTrue(result.getAssets().length > 1);
  }
コード例 #6
0
  private Asset[] getAssetsByOid(
      Oid oid,
      Collection<IAttributeDefinition> attributesToQuery,
      IFilterTerm filter,
      boolean historicalQuery)
      throws Exception {
    Query query = new Query(oid, historicalQuery);
    query.getSelection().addAll(attributesToQuery);

    if (filter != null) {
      query.setFilter(filter);
    }

    return services.retrieve(query).getAssets();
  }
コード例 #7
0
  // Filter query // Find query
  @Test
  @Ignore
  public void testFindInAQuery() throws Exception {

    Asset newStoryUrgent =
        createDisposableStory(); // services.createNew(storyType,
                                 // APIClientIntegrationTestSuiteIT.get_projectId());
    IAttributeDefinition nameAttribute = storyType.getAttributeDefinition("Name");
    newStoryUrgent.setAttributeValue(
        nameAttribute, "FindAndQueryTest: Find in a Query - Urgent story");
    services.save(newStoryUrgent);

    Asset newStory =
        createDisposableStory(); // services.createNew(storyType,
                                 // APIClientIntegrationTestSuiteIT.get_projectId());
    nameAttribute = storyType.getAttributeDefinition("Name");
    newStory.setAttributeValue(nameAttribute, "FindAndQueryTest: Find in a Query - Common story");
    services.save(newStory);
    //		query
    IAssetType requestType = metaModel.getAssetType("Story");
    Query query = new Query(requestType);
    IAttributeDefinition nameAttributeToQuery = requestType.getAttributeDefinition("Name");
    query.getSelection().add(nameAttributeToQuery);

    //		find
    IAttributeDefinition nameAttributeToFindQuery = requestType.getAttributeDefinition("Name");
    AttributeSelection selection = new AttributeSelection();
    selection.add(nameAttributeToFindQuery);
    query.setFind(new QueryFind("Urgent", selection));
    QueryResult result = services.retrieve(query);
    Asset urgentStory = result.getAssets()[0];

    Assert.assertEquals(
        "FindAndQueryTest: Find in a Query - Urgent story",
        urgentStory.getAttribute(nameAttribute).getValue().toString());
  }