private List<String> dependenciesOf(Package source) {
   List<String> result = new ArrayList<>();
   if (source.isAnnotationPresent(DependsUpon.class))
     for (Class<?> target : source.getAnnotation(DependsUpon.class).packagesOf())
       result.add(target.getPackage().getName());
   return result;
 }
  @Test // Uses of JMockit API: 8
  public void useArgumentMatchers() {
    new Expectations() {
      {
        // Using built-in matchers:
        mockedList.get(anyInt);
        result = "element";

        // Using Hamcrest matchers:
        mockedList.get(withArgThat(is(equalTo(5))));
        result = new IllegalArgumentException();
        minTimes = 0;
        mockedList.contains(withArgThat(hasProperty("bytes")));
        result = true;
        mockedList.containsAll(withArgThat(hasSize(2)));
        result = true;
      }
    };

    assertEquals("element", mockedList.get(999));
    assertTrue(mockedList.contains("abc"));
    assertTrue(mockedList.containsAll(asList("a", "b")));

    new Verifications() {
      {
        mockedList.get(anyInt);
      }
    };
  }
  /**
   * Create business object instances via API (not via process instances) and validate if they're
   * created and if a business object query for a given primary key returns the corresponding BO.
   */
  @Test
  public void CreateCustomersCheck() {
    DeployedModelDescription model =
        sf.getQueryService().getModels(DeployedModelQuery.findActiveForId(MODEL_NAME2)).get(0);
    for (int i = 1; i <= 3; i++) {
      createCustomer(model, i);
    }

    String businessObjectQualifiedId = new QName(model.getId(), "Customer").toString();
    BusinessObjectQuery query =
        BusinessObjectQuery.findForBusinessObject(businessObjectQualifiedId);
    query.setPolicy(new BusinessObjectQuery.Policy(BusinessObjectQuery.Option.WITH_VALUES));
    BusinessObjects bos = sf.getQueryService().getAllBusinessObjects(query);
    Assert.assertEquals("Objects", 1, bos.getSize());
    BusinessObject bo = bos.get(0);
    List<BusinessObject.Value> values = bo.getValues();
    Assert.assertEquals("Values", 3, values.size());

    query = BusinessObjectQuery.findWithPrimaryKey(businessObjectQualifiedId, 2);
    query.setPolicy(new BusinessObjectQuery.Policy(BusinessObjectQuery.Option.WITH_VALUES));
    bos = sf.getQueryService().getAllBusinessObjects(query);
    Assert.assertEquals("Objects", 1, bos.getSize());
    bo = bos.get(0);
    values = bo.getValues();
    Assert.assertEquals("Values", 1, values.size());
    checkValue(values, true, "firstName", "Danny2");
  }
  @Test
  public void testAdd() throws DatabaseException {

    Project census = new Project("census", 2, 3, 4, 5);
    Project births = new Project("births", 6, 7, 8, 9);

    dbProjects.add(census);
    dbProjects.add(births);

    List<Project> all = dbProjects.getAll();
    assertEquals(2, all.size());

    boolean foundAge = false;
    boolean foundPlace = false;

    for (Project p : all) {

      assertFalse(p.getId() == -1);

      if (!foundAge) {
        foundAge = areEqual(p, census, false);
      }
      if (!foundPlace) {
        foundPlace = areEqual(p, births, false);
      }
    }

    assertTrue(foundAge && foundPlace);
  }
 @Test
 public void should_return_values_of_property() {
   List<Long> ids = new ArrayList<Long>();
   ids.add(yoda.getId());
   when(propertySupport.propertyValues(propertyName, Long.class, employees)).thenReturn(ids);
   assertSame(ids, properties.from(employees));
 }
Exemplo n.º 6
0
 List<ANTLRMessage> getMessagesOfType(List<ANTLRMessage> msgs, Class c) {
   List<ANTLRMessage> filtered = new ArrayList<ANTLRMessage>();
   for (ANTLRMessage m : msgs) {
     if (m.getClass() == c) filtered.add(m);
   }
   return filtered;
 }
  @Before
  public void setup() {
    for (int customerId = 1; customerId <= 5; customerId++) {
      ProcessInstance pi =
          sf.getWorkflowService()
              .startProcess(new QName(MODEL_NAME2, "OrderCreation").toString(), null, true);
      List<ActivityInstance> w = getWorklist();
      Assert.assertEquals("worklist", 1, w.size());
      ActivityInstance ai = w.get(0);
      Assert.assertEquals("process instance", pi.getOID(), ai.getProcessInstanceOID());
      Assert.assertEquals("activity instance", "EnterOrderData", ai.getActivity().getId());
      Map<String, Object> order = CollectionUtils.newMap();
      order.put("date", new Date());
      order.put("customerId", customerId);
      ai =
          complete(
              ai, PredefinedConstants.DEFAULT_CONTEXT, Collections.singletonMap("Order", order));

      try {
        ProcessInstanceStateBarrier.instance().await(pi.getOID(), ProcessInstanceState.Completed);
      } catch (Exception e) {
      }
      w = getWorklist();
    }
  }
Exemplo n.º 8
0
  @Test
  public void postComments() {
    // Create a new user and save it
    User bob = new User("*****@*****.**", "secret", "Bob").save();

    // Create a new post
    Post bobPost = new Post(bob, "My first post", "Hello world").save();

    // Post a first comment
    new Comment(bobPost, "Jeff", "Nice Post").save();
    new Comment(bobPost, "Tom", "I knew that !").save();

    // Retrieve all comments
    List<Comment> bobPostComments = Comment.find("byPost", bobPost).fetch();

    // Tests
    assertEquals(2, bobPostComments.size());

    Comment firstComment = bobPostComments.get(0);
    assertNotNull(firstComment);
    assertEquals("Jeff", firstComment.author);
    assertEquals("Nice Post", firstComment.content);
    assertNotNull(firstComment.postedAt);

    Comment secondComment = bobPostComments.get(1);
    assertNotNull(secondComment);
    assertEquals("Tom", secondComment.author);
    assertEquals("I knew that !", secondComment.content);
    assertNotNull(secondComment.postedAt);
  }
Exemplo n.º 9
0
 @Test
 public void findRepostByTags_String_単数_投稿者_00() {
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByTags("tag-goro-red").contributor(acnt).fetch();
   assertThat(lst.size(), is(3));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 10
0
 // -------------------------------------+
 @Test
 public void findRepostByTags_Entity_単数_00() {
   Tag tag1 = Tag.findBySerialCode("tag-goro-red").first();
   List<RepostBase> lst = RepostBase.findRepostByTags(tag1).fetch();
   assertThat(lst.size(), is(3));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 11
0
 // -------------------------------------+
 @Test
 public void findRepostByUsers_Entity_単数_00() {
   User usr1 = User.findBySerialCode("usr-goro").first();
   List<RepostBase> lst = RepostBase.findRepostByUsers(usr1).fetch();
   assertThat(lst.size(), is(4));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 12
0
 // -------------------------------------+
 @Test
 public void findRepostByCategories_Entity_単数_00() {
   Category cat1 = Category.findBySerialCode("cat-biz").first();
   List<RepostBase> lst = RepostBase.findRepostByCategories(cat1).fetch();
   assertThat(lst.size(), is(2));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 13
0
 // -------------------------------------+
 @Test
 public void findRepostByTweets_Entity_単数_00() {
   Tweet twt1 = Tweet.findBySerialCode("twt-goro2").first();
   List<RepostBase> lst = RepostBase.findRepostByTweets(twt1).fetch();
   assertThat(lst.size(), is(4));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 14
0
 // -------------------------------------+
 @Test
 public void findRepostByAccounts_Entity_単数_00() {
   Account acnt1 = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByAccounts(acnt1).fetch();
   assertThat(lst.size(), is(17));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 15
0
  private List<String> executeDDL(
      String ddlFileName,
      @Nullable String dataFileName,
      boolean isLocalTable,
      @Nullable String[] args)
      throws Exception {

    Path ddlFilePath = new Path(currentQueryPath, ddlFileName);
    FileSystem fs = ddlFilePath.getFileSystem(conf);
    assertTrue(ddlFilePath + " existence check", fs.exists(ddlFilePath));

    String template = FileUtil.readTextFile(new File(ddlFilePath.toUri()));
    String dataFilePath = null;
    if (dataFileName != null) {
      dataFilePath = getDataSetFile(dataFileName).toString();
    }
    String compiled = compileTemplate(template, dataFilePath, args);

    List<ParsedResult> parsedResults = SimpleParser.parseScript(compiled);
    List<String> createdTableNames = new ArrayList<String>();

    for (ParsedResult parsedResult : parsedResults) {
      // parse a statement
      Expr expr = sqlParser.parse(parsedResult.getStatement());
      assertNotNull(ddlFilePath + " cannot be parsed", expr);

      if (expr.getType() == OpType.CreateTable) {
        CreateTable createTable = (CreateTable) expr;
        String tableName = createTable.getTableName();
        assertTrue("Table creation is failed.", client.updateQuery(parsedResult.getStatement()));
        TableDesc createdTable = client.getTableDesc(tableName);
        String createdTableName = createdTable.getName();

        assertTrue(
            "table '" + createdTableName + "' creation check", client.existTable(createdTableName));
        if (isLocalTable) {
          createdTableGlobalSet.add(createdTableName);
          createdTableNames.add(tableName);
        }
      } else if (expr.getType() == OpType.DropTable) {
        DropTable dropTable = (DropTable) expr;
        String tableName = dropTable.getTableName();
        assertTrue(
            "table '" + tableName + "' existence check",
            client.existTable(CatalogUtil.buildFQName(currentDatabase, tableName)));
        assertTrue("table drop is failed.", client.updateQuery(parsedResult.getStatement()));
        assertFalse(
            "table '" + tableName + "' dropped check",
            client.existTable(CatalogUtil.buildFQName(currentDatabase, tableName)));
        if (isLocalTable) {
          createdTableGlobalSet.remove(tableName);
        }
      } else {
        assertTrue(ddlFilePath + " is not a Create or Drop Table statement", false);
      }
    }

    return createdTableNames;
  }
Exemplo n.º 16
0
 @Test
 public void findRepostByTweets_String_複数_投稿者_00() {
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst =
       RepostBase.findRepostByTweets("twt-goro2", "twt-jiro1").contributor(acnt).fetch();
   assertThat(lst.size(), is(5));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 17
0
 @Test
 public void findRepostByCategories_String_複数_投稿者_00() {
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst =
       RepostBase.findRepostByCategories("cat-biz", "cat-enta").contributor(acnt).fetch();
   assertThat(lst.size(), is(3));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 18
0
 // -------------------------------------+
 @Test
 public void findRepostByCategories_Entity_単数_投稿者_00() {
   Category cat1 = Category.findBySerialCode("cat-biz").first();
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByCategories(cat1).contributor(acnt).fetch();
   assertThat(lst.size(), is(2));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 19
0
  @Test
  public void testParameterToPairsWhenNameIsInvalid() throws Exception {
    List<Pair> pairs_a = apiClient.parameterToPairs("csv", null, new Integer(1));
    List<Pair> pairs_b = apiClient.parameterToPairs("csv", "", new Integer(1));

    assertTrue(pairs_a.isEmpty());
    assertTrue(pairs_b.isEmpty());
  }
Exemplo n.º 20
0
 // -------------------------------------+
 @Test
 public void findRepostByUsers_Entity_単数_投稿者_00() {
   User usr1 = User.findBySerialCode("usr-goro").first();
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByUsers(usr1).contributor(acnt).fetch();
   assertThat(lst.size(), is(2));
   // DBからの取得リストの並び保証なし
 }
Exemplo n.º 21
0
 static ServerMessage doTxRx(ClientMessage... cms) {
   List<ClientMessage> cmArray = new ArrayList<ClientMessage>();
   for (ClientMessage cm : cms) {
     cmArray.add(cm);
   }
   ServerMessage result = doTxRx(cmArray);
   return result;
 }
Exemplo n.º 22
0
 @Mock
 public int computeX(Invocation inv, int a, int b) {
   inputValues.add(a);
   inputValues.add(b);
   int x = inv.proceed();
   outputValues.add(x);
   return x;
 }
Exemplo n.º 23
0
 // -------------------------------------+
 @Test
 public void findRepostByTweets_Entity_単数_投稿者_00() {
   Tweet twt1 = Tweet.findBySerialCode("twt-goro2").first();
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByTweets(twt1).contributor(acnt).fetch();
   assertThat(lst.size(), is(2));
   // DBからの取得リストの並び保証なし
 }
 @Test
 public void testResolveSingletonInSameRegions() {
   List<BundleCapability> collisionCandidates = new ArrayList<BundleCapability>();
   collisionCandidates.add(bundleCapability(BUNDLE_B));
   collisionCandidates.add(bundleCapability(BUNDLE_C));
   collisionCandidates.add(bundleCapability(BUNDLE_D));
   this.resolverHook.filterSingletonCollisions(bundleCapability(BUNDLE_A), collisionCandidates);
   assertEquals("Wrong number of collitions", 0, collisionCandidates.size());
 }
Exemplo n.º 25
0
 @Test
 public void test_next() {
   List<Integer> list = new ArrayList<Integer>();
   list.add(1);
   list.add(2);
   Cursor<Integer> it = new Cursor<Integer>(list);
   assertEquals("[1,2].next", 1, (Object) it.next());
   assertEquals("[2].next", 2, (Object) it.next());
 }
Exemplo n.º 26
0
 @Test
 public void findRepostByAccounts_String_複数_降順_00() {
   List<RepostBase> lst =
       RepostBase.findRepostByAccounts("usr-goro", "usr-jiro")
           .orderBy(RepostBase.OrderBy.DATE_OF_REPOST_DESC)
           .fetch();
   assertThat(lst.size(), is(24));
   assertThat(lst.get(0).contributor.loginUser.screenName, is("goro_san"));
 }
Exemplo n.º 27
0
 @Test
 public void findRepostByTags_Entity_複数_投稿者_00() {
   Tag tag1 = Tag.findBySerialCode("tag-goro-red").first();
   Tag tag2 = Tag.findBySerialCode("tag-jiro-hello").first();
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByTags(tag1, tag2).contributor(acnt).fetch();
   assertThat(lst.size(), is(3));
   // DBからの取得リストの並び保証なし
 }
  private void doControlTask() throws IOException, ClassNotFoundException {
    BlockingTaskSummaryResponseHandler handler = new BlockingTaskSummaryResponseHandler();
    client.getTasksAssignedAsPotentialOwner("control", "en-UK", handler);
    List<TaskSummary> sums = handler.getResults();
    assertNotNull(sums);
    assertEquals(1, sums.size());

    BlockingTaskOperationResponseHandler startTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.start(sums.get(0).getId(), "control", startTaskOperationHandler);

    BlockingGetTaskResponseHandler getTaskHandler = new BlockingGetTaskResponseHandler();
    client.getTask(sums.get(0).getId(), getTaskHandler);
    Task controlTask = getTaskHandler.getTask();

    BlockingGetContentResponseHandler getContentHandler = new BlockingGetContentResponseHandler();
    client.getContent(controlTask.getTaskData().getDocumentContentId(), getContentHandler);
    Content content = getContentHandler.getContent();

    assertNotNull(content);

    ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
    ObjectInputStream ois = new ObjectInputStream(bais);
    Map<String, Object> deserializedContent = (Map<String, Object>) ois.readObject();
    Emergency retrivedEmergency = (Emergency) deserializedContent.get("emergency");
    assertNotNull(retrivedEmergency);
    ActivePatients retrivedActivePatients =
        (ActivePatients) deserializedContent.get("activePatients");
    assertNotNull(retrivedActivePatients);
    assertEquals(1, retrivedActivePatients.size());
    SuggestedProcedures retrivedSuggestedProcedures =
        (SuggestedProcedures) deserializedContent.get("suggestedProcedures");
    assertNotNull(retrivedSuggestedProcedures);
    assertEquals(
        "[DefaultHeartAttackProcedure: ]",
        retrivedSuggestedProcedures.getSuggestedProceduresString());

    Map<String, Object> info = new HashMap<String, Object>();
    SelectedProcedures selectedProcedures = new SelectedProcedures(retrivedEmergency.getId());

    selectedProcedures.addSelectedProcedureName("DefaultHeartAttackProcedure");
    info.put("selectedProcedures", selectedProcedures);

    ContentData result = new ContentData();
    result.setAccessType(AccessType.Inline);
    result.setType("java.util.Map");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bos);
    out.writeObject(info);
    out.close();
    result.setContent(bos.toByteArray());

    BlockingTaskOperationResponseHandler completeTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.complete(sums.get(0).getId(), "control", result, completeTaskOperationHandler);
  }
Exemplo n.º 29
0
 public List<Integer> getTokenTypes(String input, LexerATNSimulator lexerATN) {
   ANTLRStringStream in = new ANTLRStringStream(input);
   List<Integer> tokenTypes = new ArrayList<Integer>();
   int ttype = 0;
   do {
     ttype = lexerATN.matchATN(in);
     tokenTypes.add(ttype);
   } while (ttype != Token.EOF);
   return tokenTypes;
 }
Exemplo n.º 30
0
 List<Integer> getTypesFromString(Grammar g, String expecting) {
   List<Integer> expectingTokenTypes = new ArrayList<Integer>();
   if (expecting != null && !expecting.trim().equals("")) {
     for (String tname : expecting.replace(" ", "").split(",")) {
       int ttype = g.getTokenType(tname);
       expectingTokenTypes.add(ttype);
     }
   }
   return expectingTokenTypes;
 }