コード例 #1
0
  public void testFilterByStatus() {
    ClaimListController claimListController = new ClaimListController();

    claimListController.addClaim(
        "Claim 1",
        new GregorianCalendar().getTime(),
        new GregorianCalendar().getTime(),
        "description",
        new User("Jim", "123"));
    int claim2Id =
        claimListController.addClaim(
            "Claim 2",
            new GregorianCalendar().getTime(),
            new GregorianCalendar().getTime(),
            "description",
            new User("Jim", "123"));

    int claim3Id =
        claimListController.addClaim(
            "Claim 3",
            new GregorianCalendar().getTime(),
            new GregorianCalendar().getTime(),
            "description",
            new User("Jim", "123"));

    Claim claim2 = claimListController.getClaim(claim2Id);
    Claim claim3 = claimListController.getClaim(claim3Id);
    claim2.setStatus("Approved");
    claim3.setStatus("Approved");

    ArrayList<Claim> approvedClaims = claimListController.filterByStatus("Approved");

    assertEquals("The number of 'Approved' claims doesn't match", 2, approvedClaims.size());
  }
コード例 #2
0
  public void testFilteredByTag() {
    ClaimListController claimListController = new ClaimListController();

    int claim1Id =
        claimListController.addClaim(
            "Claim 1",
            new GregorianCalendar().getTime(),
            new GregorianCalendar().getTime(),
            "description",
            new User("Jim", "123"));
    int claim2Id =
        claimListController.addClaim(
            "Claim 2",
            new GregorianCalendar().getTime(),
            new GregorianCalendar().getTime(),
            "description",
            new User("Jim", "123"));

    Claim claim1 = claimListController.getClaim(claim1Id);
    Claim claim2 = claimListController.getClaim(claim2Id);
    try {
      claim1.addTag("cat");
      claim2.addTag("cat");
      ArrayList<String> tags = new ArrayList<String>();
      tags.add("cat");
      assertEquals(
          "there should be two claims with tag 'cat'",
          2,
          claimListController.filterByTag("Jim", tags).size());
    } catch (AlreadyExistsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #3
0
 // US01.05.01
 public void testRemoveClaim() {
   ClaimListController clc = new ClaimListController();
   clc.clear();
   Date date1 = new Date();
   Date date2 = new Date();
   User user = new User("name", "123");
   clc.addClaim("Claim", date1, date2, "description", user);
   assertEquals("claim was not added", 1, clc.size());
   if (clc.getClaim(0).editable()) {
     clc.removeClaim(0);
     assertEquals("claim was not removed", 0, clc.size());
   } else {
     // cannot remove claim, do nothing
   }
 }