@Test
  public void testSendAccountBean() throws Exception {
    MockEndpoint endpoint = getMockEndpoint("mock:results");
    endpoint.expectedMinimumMessageCount(1);

    Account account = new Account();
    account.setId(123);
    account.setFirstName("James");
    account.setLastName("Strachan");
    account.setEmailAddress("*****@*****.**");

    template.sendBody("direct:start", account);

    assertMockEndpointsSatisfied();

    // now lets poll that the account has been inserted
    List body =
        template.requestBody(
            "ibatis:selectAllAccounts?statementType=QueryForList", null, List.class);

    assertEquals("Wrong size: " + body, 1, body.size());
    Account actual = assertIsInstanceOf(Account.class, body.get(0));

    assertEquals("Account.getFirstName()", "James", actual.getFirstName());
    assertEquals("Account.getLastName()", "Strachan", actual.getLastName());

    log.info("Found: " + actual);
  }
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();

    // super will insert 2 accounts already

    Account account = new Account();
    account.setId(881);
    account.setFirstName("A");
    account.setLastName("A");
    account.setEmailAddress("*****@*****.**");

    template.sendBody("ibatis:insertAccount?statementType=Insert", account);

    account = new Account();
    account.setId(882);
    account.setFirstName("B");
    account.setLastName("B");
    account.setEmailAddress("*****@*****.**");

    template.sendBody("ibatis:insertAccount?statementType=Insert", account);

    account = new Account();
    account.setId(883);
    account.setFirstName("C");
    account.setLastName("C");
    account.setEmailAddress("*****@*****.**");

    template.sendBody("ibatis:insertAccount?statementType=Insert", account);

    account = new Account();
    account.setId(884);
    account.setFirstName("D");
    account.setLastName("D");
    account.setEmailAddress("*****@*****.**");

    template.sendBody("ibatis:insertAccount?statementType=Insert", account);

    account = new Account();
    account.setId(885);
    account.setFirstName("E");
    account.setLastName("E");
    account.setEmailAddress("*****@*****.**");

    template.sendBody("ibatis:insertAccount?statementType=Insert", account);

    account = new Account();
    account.setId(886);
    account.setFirstName("F");
    account.setLastName("F");
    account.setEmailAddress("*****@*****.**");

    template.sendBody("ibatis:insertAccount?statementType=Insert", account);
  }
  @Test
  public void manyToOne_setAccount() {
    SavedSearch many = new SavedSearch();

    // init
    Account one = new Account();
    one.setId(ValueGenerator.getUniqueString(36));
    many.setAccount(one);

    // make sure it is propagated properly
    assertThat(many.getAccount()).isEqualTo(one);

    // now set it to back to null
    many.setAccount(null);

    // make sure null is propagated properly
    assertThat(many.getAccount()).isNull();
  }
    public void action() {

      try {
        ContentElement content = getContentManager().extractContent(request);
        CreateAccount ca = (CreateAccount) ((Action) content).getAction();
        Account acc = new Account();
        String id = generateId();
        acc.setId(id);
        acc.setName(ca.getName());
        Result result = new Result((Action) content, acc);
        ACLMessage reply = request.createReply();
        reply.setPerformative(ACLMessage.INFORM);
        getContentManager().fillContent(reply, result);
        send(reply);
        accounts.put(id, acc);
        operations.put(id, new ArrayList());
        System.out.println("Account [" + acc.getName() + " # " + acc.getId() + "] created!");
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
Exemple #5
0
 private Account parseAccount(Node node) {
   String id = getAttribute(node, ACCOUNT_ATTR_ID);
   String type = getAttribute(node, ACCOUNT_ATTR_TYPE, "");
   String name = getAttribute(node, ACCOUNT_ATTR_NAME, "");
   String comment = getAttribute(node, ACCOUNT_ATTR_COMMENT, "");
   HashMap<String, String> params = new HashMap<String, String>();
   NodeList nodes = node.getChildNodes();
   for (int i = 0; i < nodes.getLength(); i++) {
     Node subNode = nodes.item(i);
     if (subNode.getNodeType() != Node.ELEMENT_NODE) {
       continue;
     }
     if (PARAM_NODE_NAME.equals(subNode.getNodeName())) {
       String pName = getAttribute(subNode, PARAM_ATTR_NAME);
       String pValue = getAttribute(subNode, PARAM_ATTR_VALUE);
       if (pName != null && pValue != null) {
         params.put(pName, pValue);
       }
     }
   }
   Account account;
   if (SSHAccount.SSHACCOUNT_TYPE.equalsIgnoreCase(type)) {
     account = new SSHAccount();
   } else if (HTTPAccount.HTTPACCOUNT_TYPE.equalsIgnoreCase(type)) {
     account = new HTTPAccount();
   } else {
     account = new Account();
   }
   account.setId(id);
   account.setType(type);
   account.setName(name);
   account.setComment(comment);
   account.setParams(params);
   accounts.put(account.getId(), account);
   String through = account.getParams().get(ACCOUNT_PARAM_THROUGH);
   if (!Util.isEmptyOrNull(through)) {
     needsThrough.put(account, through);
   }
   return account;
 }