Esempio n. 1
0
  @SuppressWarnings("unchecked")
  @Test
  public void testFindCustomersWithConnection() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("readNextCustomer")
            .addMockedMethod("getCustomerQuery")
            .createStrictMock();
    ResultSet resultSet = EasyMock.createStrictMock(ResultSet.class);
    Connection connection = EasyMock.createStrictMock(Connection.class);
    Statement statement = EasyMock.createStrictMock(Statement.class);
    List<SearchConstraint> constraints = new LinkedList<SearchConstraint>();

    EasyMock.expect(dao.getCustomerQuery(constraints)).andReturn("aQuery");
    EasyMock.expect(connection.createStatement()).andReturn(statement);
    EasyMock.expect(statement.executeQuery("aQuery")).andReturn(resultSet);

    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(dao.readNextCustomer(EasyMock.eq(resultSet), EasyMock.isA(List.class)))
        .andReturn(true);
    EasyMock.expect(dao.readNextCustomer(EasyMock.eq(resultSet), EasyMock.isA(List.class)))
        .andReturn(true);
    EasyMock.expect(dao.readNextCustomer(EasyMock.eq(resultSet), EasyMock.isA(List.class)))
        .andReturn(false);
    resultSet.close();
    EasyMock.expectLastCall();
    statement.close();
  }
Esempio n. 2
0
  @SuppressWarnings("unchecked")
  @Test
  public void testAppendCloudServiceGuidConstraint() throws Exception {
    CustomerDAO dao = new CustomerDAO();

    // list
    List<String> list = new LinkedList<String>();
    list.add("val1");
    list.add("val2");
    SearchConstraint sc =
        new SearchConstraint("TEST_PROP", SearchConstraintOperator.CONSTRAINT_IN_LIST, list);
    String got = dao.appendCloudServiceGuidConstraint(sc);
    String expected =
        CustomerDAO.SQL_CUSTOMER_QUERY_CLOUD_SERVICE_CONSTRAINT + "in (E'val1',E'val2'))";
    assertEquals("Wrong constraint added.", expected, got);

    // equal
    sc =
        new SearchConstraint(
            ICustomerService.PROP_CLOUD_SERVICE_GUID,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "val3");
    got = dao.appendCloudServiceGuidConstraint(sc);
    expected =
        CustomerDAO.SQL_CUSTOMER_QUERY_CLOUD_SERVICE_CONSTRAINT
            + "= E'val3' and g_inner.disabled = false)";
    assertEquals("Wrong constraint added.", expected, got);
  }
Esempio n. 3
0
  @Test
  public void testReadDomainsAndGuids() throws Exception {
    CustomerDAO dao = new CustomerDAO();
    IConfiguration configuration = EasyMock.createStrictMock(IConfiguration.class);
    dao.setConfiguration(configuration);
    ResultSet resultSet = EasyMock.createStrictMock(ResultSet.class);
    Set<String> domains = new HashSet<String>();
    Set<GlobalIdentifier> guids = new HashSet<GlobalIdentifier>();
    int custId = 34;
    int cloudService = 2;
    int replicationZone = 453;

    int cloudService2 = 1;
    int replicationZone2 = 13;

    int cloudService3 = 3;

    // first exec of loop
    EasyMock.expect(resultSet.getString(10)).andReturn("domain123");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid123");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService);
    EasyMock.expect(resultSet.getInt(13)).andReturn(replicationZone);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId);

    // second exec of loop
    EasyMock.expect(resultSet.getString(10)).andReturn("domain456");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid456");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService2);
    EasyMock.expect(resultSet.getInt(13)).andReturn(replicationZone2);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId);

    // third exec of loop (guid not valid with no cloud service)
    EasyMock.expect(resultSet.getString(10)).andReturn("domain456");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid789");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService3);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId + 1); // ends loop with mismatched custid

    EasyMock.replay(resultSet);
    assertTrue(
        "Should have another item even.",
        dao.readDomainsAndGuids(resultSet, custId, domains, guids));
    EasyMock.verify(resultSet);
    assertEquals("Should have 2 domains.", 2, domains.size());
    assertTrue("Domain123 not found.", domains.contains("domain123"));
    assertTrue("Domain456 not found.", domains.contains("domain456"));

    assertEquals("Should have 2 guids.", 2, guids.size());
    for (GlobalIdentifier guid : guids) {
      if (guid.getGuid().equals("guid123")) {
        assertEquals("Wrong cloud service in guid123", CloudService.GOOGLE, guid.getService());
        assertEquals("Wrong replication zone.", replicationZone, guid.getReplicationZone());
      } else {
        assertEquals("Wrong cloud service in guid456", CloudService.OFFICE365, guid.getService());
        assertEquals("Wrong replication zone.", replicationZone2, guid.getReplicationZone());
      }
    }
  }
Esempio n. 4
0
  @Test
  public void testGettersAndSetters() throws Exception {
    CustomerDAO dao = new CustomerDAO();
    ITransactionManager txMgr = EasyMock.createStrictMock(ITransactionManager.class);
    IConfiguration configuration = EasyMock.createStrictMock(IConfiguration.class);

    dao.setTransactionManager(txMgr);
    dao.setConfiguration(configuration);

    assertEquals("Wrong transaction manager.", txMgr, dao.getTransactionManager());
    assertEquals("Wrong customer service.", configuration, dao.getConfiguration());
  }
Esempio n. 5
0
  @SuppressWarnings("unchecked")
  @Test
  public void testAppendUserStateConstraint() throws Exception {
    CustomerDAO dao = new CustomerDAO();

    SearchConstraint sc =
        new SearchConstraint(
            ICustomerService.PROP_USERS_IN_STATE,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "val3");
    String got = dao.appendUserStateConstraint(sc);
    String expected =
        CustomerDAO.SQL_CUSTOMER_QUERY_USER_CONSTRAINT + "= E'val3' and uc.user_count > 0) ";
    assertEquals("Wrong constraint added.", expected, got);
  }
Esempio n. 6
0
  @SuppressWarnings("unchecked")
  @Test
  public void testAppendCustomerPrefixConstraint() throws Exception {
    CustomerDAO dao = new CustomerDAO();

    StringBuffer clause = new StringBuffer();

    SearchConstraint sc =
        new SearchConstraint(
            ICustomerService.PROP_CUST_CAPABILITY_PREFIX,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "val3");
    dao.appendCustomerPrefixConstraint(sc, clause);
    String expected =
        " c.customer_id in ( select customer_id from dat_customer_capabilities where cap_value = E'val3' and cap_name = E'' ) ";
    assertEquals("Wrong constraint added.", expected, clause.toString());
  }
Esempio n. 7
0
  @Test
  public void testGetCustomerQuery() throws Exception {
    List<SearchConstraint> constraintList = new LinkedList<SearchConstraint>();

    CustomerDAO dao =
        new CustomerDAO() {
          @Override
          protected void appendConstraints(
              List<SearchConstraint> constraints, StringBuilder whereClause) {
            whereClause.append("hello world");
          }
        };

    String expected =
        CustomerDAO.SQL_CUSTOMER_QUERY + "hello world" + CustomerDAO.SQL_CUSTOMER_QUERY_ORDER_BY;
    assertEquals(
        "Wrong query with no constraints.", expected, dao.getCustomerQuery(constraintList));
  }
Esempio n. 8
0
  @Test
  public void testGetCustomerWithConnection() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("findCustomers", List.class, Connection.class)
            .createStrictMock();
    Customer customer = EasyMock.createStrictMock(Customer.class);
    Connection connection = EasyMock.createStrictMock(Connection.class);
    int custId = 322;
    List<ICustomer> customerList = new LinkedList<ICustomer>();
    customerList.add(customer);

    Capture<List<SearchConstraint>> capture = new Capture<List<SearchConstraint>>();
    EasyMock.expect(dao.findCustomers(EasyMock.capture(capture), EasyMock.eq(connection)))
        .andReturn(customerList);

    EasyMock.replay(dao, customer, connection);
    assertEquals("Wrong customer returned.", customer, dao.getCustomer(custId, connection));
    EasyMock.verify(dao, customer, connection);
    assertEquals("Wrong # of constraints.", 1, capture.getValue().size());
    SearchConstraint constraint = capture.getValue().get(0);
    assertEquals(
        "Wrong property in constraint.",
        ICustomerService.PROP_CUSTOMER_ID,
        constraint.getProperty());
    assertEquals(
        "Wrong operator in constraint.",
        SearchConstraintOperator.CONSTRAINT_EQUALS,
        constraint.getOperator());
    assertEquals("Wrong value in constraint.", custId, constraint.getValue());

    // no customers
    customerList.clear();
    EasyMock.reset(dao, customer, connection);
    capture = new Capture<List<SearchConstraint>>();
    EasyMock.expect(dao.findCustomers(EasyMock.capture(capture), EasyMock.eq(connection)))
        .andReturn(customerList);

    EasyMock.replay(dao, customer, connection);
    assertEquals(
        "Should not have found a customer returned.", null, dao.getCustomer(custId, connection));
    EasyMock.verify(dao, customer, connection);
  }
Esempio n. 9
0
  @Test
  public void testGetCustomer() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("getCustomer", Integer.TYPE, Connection.class)
            .createStrictMock();
    Customer customer = EasyMock.createStrictMock(Customer.class);
    ITransactionManager txMgr = EasyMock.createStrictMock(ITransactionManager.class);
    dao.setTransactionManager(txMgr);
    Connection connection = EasyMock.createStrictMock(Connection.class);
    int custId = 322;

    EasyMock.expect(dao.getCustomer(custId, connection)).andReturn(customer);
    CustomerTestUtils.MockJoinAndExecuteWithConnection.<Customer>execute(txMgr, connection);

    EasyMock.replay(dao, customer, txMgr, connection);
    assertEquals("Wrong customer returned.", customer, dao.getCustomer(custId));
    EasyMock.verify(dao, customer, txMgr, connection);
  }
Esempio n. 10
0
  @Test
  public void testFindCustomers() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("findCustomers", List.class, Connection.class)
            .createStrictMock();
    ITransactionManager txMgr = EasyMock.createStrictMock(ITransactionManager.class);
    dao.setTransactionManager(txMgr);
    Connection connection = EasyMock.createStrictMock(Connection.class);
    List<SearchConstraint> constraints = new LinkedList<SearchConstraint>();
    List<ICustomer> customerList = new LinkedList<ICustomer>();

    EasyMock.expect(dao.findCustomers(constraints, connection)).andReturn(customerList);
    CustomerTestUtils.MockExecuteWithConnection.<Customer>execute(txMgr, connection);

    EasyMock.replay(dao, txMgr, connection);
    assertEquals("Wrong customer list returned.", customerList, dao.findCustomers(constraints));
    EasyMock.verify(dao, txMgr, connection);
  }
Esempio n. 11
0
  @SuppressWarnings("unchecked")
  @Test
  public void testAppendDomainConstraint() throws Exception {
    CustomerDAO dao = new CustomerDAO();

    // list
    List<String> list = new LinkedList<String>();
    list.add("domain0");
    list.add("domain1");
    SearchConstraint sc =
        new SearchConstraint("TEST_PROP", SearchConstraintOperator.CONSTRAINT_IN_LIST, list);
    String got = dao.appendDomainConstraint(sc);
    String expected =
        CustomerDAO.SQL_CUSTOMER_QUERY_DOMAIN_CONSTRAINT + "in (E'domain0',E'domain1'))";
    assertEquals("Wrong constraint added.", expected, got);

    // equal
    sc = new SearchConstraint("TEST_PROP", SearchConstraintOperator.CONSTRAINT_EQUALS, "domain3");
    got = dao.appendDomainConstraint(sc);
    expected = CustomerDAO.SQL_CUSTOMER_QUERY_DOMAIN_CONSTRAINT + "= E'domain3')";
    assertEquals("Wrong constraint added.", expected, got);
  }
Esempio n. 12
0
  @SuppressWarnings("unchecked")
  @Test
  public void testReadNextCustomer() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("readDomainsAndGuids")
            .createStrictMock();
    ResultSet resultSet = EasyMock.createStrictMock(ResultSet.class);
    List<ICustomer> customerList = new LinkedList<ICustomer>();

    int custID = 34;
    int state = 3;
    String name = "myName";
    String fromAddress = "myFromAddr";
    String clientID = "myClientId";
    String clientKey = "myClientKey";
    String backendId = "myBackendId";
    String templateId = "myTemplateId";
    String externalID = "myExternalId";
    int estMailboxCount = 34453;
    int estCloudMailboxCount = 345234;
    int estOnpremisesJournalMailboxCount = 3523;
    int estWelcomedCount = 938423;
    int estNotificationCount = 3423;
    int estAdminCount = 45345;
    Date countsUpdatedTime = new Date();
    int estTotalContacts = 345234;
    int estTotalUsersWithContacts = 87432;
    int estTotalCalendarEntries = 343460;
    int estTotalUsersWithCalendar = 9892;
    int estTotalDLists = 8932;
    int estTotalDListMembers = 34982;
    int estTotalPDLs = 12342142;
    int estTotalPDLMembers = 8732324;
    int estNoWelcomeResponseCount = 734232;
    int estNoLoginCount = 90832;
    int estNoActiveLoginCount = 89923;
    int estIgnoredCount = 349823;
    String channel = "myChannel";

    EasyMock.expect(resultSet.getInt(1)).andReturn(custID);
    EasyMock.expect(resultSet.getInt(2)).andReturn(state);
    EasyMock.expect(resultSet.getString(3)).andReturn(name);
    EasyMock.expect(resultSet.getString(4)).andReturn(fromAddress);
    EasyMock.expect(resultSet.getString(5)).andReturn(clientID);
    EasyMock.expect(resultSet.getString(6)).andReturn(clientKey);
    EasyMock.expect(resultSet.getString(7)).andReturn(backendId);
    EasyMock.expect(resultSet.getString(8)).andReturn(templateId);
    EasyMock.expect(resultSet.getString(9)).andReturn(externalID);
    EasyMock.expect(resultSet.getInt(14)).andReturn(estMailboxCount);
    EasyMock.expect(resultSet.getInt(15)).andReturn(estCloudMailboxCount);
    EasyMock.expect(resultSet.getInt(16)).andReturn(estOnpremisesJournalMailboxCount);
    EasyMock.expect(resultSet.getInt(17)).andReturn(estWelcomedCount);
    EasyMock.expect(resultSet.getInt(18)).andReturn(estNotificationCount);
    EasyMock.expect(resultSet.getInt(19)).andReturn(estAdminCount);
    EasyMock.expect(resultSet.getTimestamp(20))
        .andReturn(new Timestamp(countsUpdatedTime.getTime()));
    EasyMock.expect(resultSet.getInt(21)).andReturn(estTotalContacts);
    EasyMock.expect(resultSet.getInt(22)).andReturn(estTotalUsersWithContacts);
    EasyMock.expect(resultSet.getInt(23)).andReturn(estTotalCalendarEntries);
    EasyMock.expect(resultSet.getInt(24)).andReturn(estTotalUsersWithCalendar);
    EasyMock.expect(resultSet.getInt(25)).andReturn(estTotalDLists);
    EasyMock.expect(resultSet.getInt(26)).andReturn(estTotalDListMembers);
    EasyMock.expect(resultSet.getInt(27)).andReturn(estTotalPDLs);
    EasyMock.expect(resultSet.getInt(28)).andReturn(estTotalPDLMembers);
    EasyMock.expect(resultSet.getInt(29)).andReturn(estNoWelcomeResponseCount);
    EasyMock.expect(resultSet.getInt(30)).andReturn(estNoLoginCount);
    EasyMock.expect(resultSet.getInt(31)).andReturn(estNoActiveLoginCount);
    EasyMock.expect(resultSet.getInt(32)).andReturn(estIgnoredCount);
    EasyMock.expect(resultSet.getString(33)).andReturn(channel);

    EasyMock.expect(
            dao.readDomainsAndGuids(
                EasyMock.eq(resultSet),
                EasyMock.eq(custID),
                EasyMock.isA(Set.class),
                EasyMock.isA(Set.class)))
        .andReturn(true);

    EasyMock.replay(dao, resultSet);
    assertTrue(
        "Should have found another customer.", dao.readNextCustomer(resultSet, customerList));
    EasyMock.verify(dao, resultSet);

    assertEquals("Should have customer in list.", 1, customerList.size());
    Customer cust = (Customer) customerList.get(0);

    assertEquals("Wrong customer id.", custID, cust.getCustID());
    assertEquals("Wrong customer state.", state, cust.getState().toInt());
    assertEquals("Wrong customer name.", name, cust.getName());
    assertEquals("Wrong from address.", fromAddress, cust.getFromAddress());
    assertEquals("Wrong backend id.", backendId, cust.getBackendHostname());
    assertEquals("Wrong template id.", templateId, cust.getTemplateId());
    assertEquals("Wrong channel.", channel, cust.getChannel());
    assertEquals("Wrong client id.", clientID, cust.getClientID());
    assertEquals("Wrong client key.", clientKey, cust.getClientKey());
    assertEquals("Wrong channel.", channel, cust.getChannel());
    assertEquals("Wrong est mailbox count.", estMailboxCount, cust.getEstMailboxCount());
    assertEquals(
        "Wrong est cloud mailbox count.", estCloudMailboxCount, cust.getEstCloudMailboxCount());
    assertEquals(
        "Wrong est on premises journal mailbox count.",
        estOnpremisesJournalMailboxCount,
        cust.getEstOnpremisesJournalMailboxCount());
    assertEquals("Wrong est not welcomed count.", estWelcomedCount, cust.getEstNotWelcomedCount());
    assertEquals(
        "Wrong est notification not set count.",
        estNotificationCount,
        cust.getEstNotificationNotSetCount());
    assertEquals("Wrong est admin count.", estAdminCount, cust.getEstAdminCount());
    assertEquals("Wrong counts updated time.", countsUpdatedTime, cust.getCountsUpdatedTime());
    assertEquals("Wrong total contacts.", estTotalContacts, cust.getTotalContacts());
    assertEquals(
        "Wrong total users with contacts.",
        estTotalUsersWithContacts,
        cust.getTotalUsersWithContacts());
    assertEquals(
        "Wrong total calendar entries.", estTotalCalendarEntries, cust.getTotalCalendarEntries());
    assertEquals(
        "Wrong total users with calendar entries.",
        estTotalUsersWithCalendar,
        cust.getTotalUsersWithCalendarEntries());
    assertEquals("Wrong total dlists.", estTotalDLists, cust.getTotalDlists());
    assertEquals("Wrong total dlist members.", estTotalDListMembers, cust.getTotalDlistMembers());
    assertEquals("Wrong total pdls.", estTotalPDLs, cust.getTotalPDLs());
    assertEquals("Wrong total pdl members.", estTotalPDLMembers, cust.getTotalPDLMembers());
    assertEquals(
        "Wrong est no welcome reponse count.",
        estNoWelcomeResponseCount,
        cust.getEstNoWelcomeResponseCount());
    assertEquals("Wrong est no login count.", estNoLoginCount, cust.getEstNoLoginCount());
    assertEquals(
        "Wrong est no active login count.", estNoActiveLoginCount, cust.getEstNoActiveLoginCount());
    assertEquals("Wrong est ignored count.", estIgnoredCount, cust.getEstIgnoredCount());
    assertEquals("Wrong external id.", externalID, cust.getExternalID());
  }
Esempio n. 13
0
  @SuppressWarnings("unchecked")
  @Test
  public void testAppendConstraints() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("appendDomainConstraint")
            .addMockedMethod("appendCloudServiceGuidConstraint")
            .addMockedMethod("appendCustomerPrefixConstraint")
            .addMockedMethod("appendUserStateConstraint")
            .createStrictMock();
    List<SearchConstraint> constraints = new LinkedList<SearchConstraint>();

    // domain constraint
    SearchConstraint sc =
        new SearchConstraint(
            ICustomerService.PROP_DOMAINS, SearchConstraintOperator.CONSTRAINT_EQUALS, "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendDomainConstraint(EasyMock.eq(sc))).andReturn("a");

    // cloud service guid
    sc =
        new SearchConstraint(
            ICustomerService.PROP_CLOUD_SERVICE_GUID,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendCloudServiceGuidConstraint(EasyMock.eq(sc))).andReturn("b");
    sc =
        new SearchConstraint(
            ICustomerService.PROP_CLOUD_SERVICE_ANY_GUID,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendCloudServiceGuidConstraint(EasyMock.eq(sc))).andReturn("c");

    // customer prefix
    sc =
        new SearchConstraint(
            ICustomerService.PROP_CUST_CAPABILITY_PREFIX,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    dao.appendCustomerPrefixConstraint(EasyMock.eq(sc), EasyMock.isA(StringBuffer.class));
    EasyMock.expectLastCall();

    // users in state
    sc =
        new SearchConstraint(
            ICustomerService.PROP_USERS_IN_STATE,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendUserStateConstraint(EasyMock.eq(sc))).andReturn("d");

    // users NOT in state
    sc =
        new SearchConstraint(
            ICustomerService.PROP_NO_USERS_IN_STATE,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendUserStateConstraint(EasyMock.eq(sc))).andReturn("e");

    StringBuilder whereClause = new StringBuilder();
    EasyMock.replay(dao);
    dao.appendConstraints(constraints, whereClause);
    EasyMock.verify(dao);

    String expected = " and (a) and (b) and (c) and (not )";
    assertEquals("Wrong where clause returned.", expected, whereClause.toString());
  }
Esempio n. 14
0
 @Test
 public void testConstructor() throws Exception {
   CustomerDAO dao = new CustomerDAO();
   assertNull("txManager should be null.", dao.getTransactionManager());
 }
Esempio n. 15
0
  @Test
  public void testFindCustomerByGuid() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("findCustomers", List.class)
            .createStrictMock();

    // null guid
    EasyMock.replay(dao);
    try {
      dao.findCustomerByGuid(null, true);
      fail("Should have thrown an exception when null guid passed in.");
    } catch (IllegalArgumentException ex) {
      // expected
    }
    EasyMock.verify(dao);

    // no customer found
    EasyMock.reset(dao);
    boolean allowDeleted = true;
    String guid = "myGuid";
    Capture<List<SearchConstraint>> capture = new Capture<List<SearchConstraint>>();
    List<ICustomer> customerList = new LinkedList<ICustomer>();
    EasyMock.expect(dao.findCustomers(EasyMock.capture(capture))).andReturn(customerList);
    EasyMock.replay(dao);
    assertNull("Should not have found a customer.", dao.findCustomerByGuid(guid, allowDeleted));
    EasyMock.verify(dao);
    assertEquals("Wrong # of constraints.", 1, capture.getValue().size());
    SearchConstraint constraint = capture.getValue().get(0);
    assertEquals(
        "Wrong property in constraint.",
        ICustomerService.PROP_CLOUD_SERVICE_ANY_GUID,
        constraint.getProperty());
    assertEquals(
        "Wrong operator in constraint.",
        SearchConstraintOperator.CONSTRAINT_EQUALS,
        constraint.getOperator());
    assertEquals("Wrong value in constraint.", guid, constraint.getValue());

    // customer found and don't allow deleted
    EasyMock.reset(dao);
    allowDeleted = false;
    capture = new Capture<List<SearchConstraint>>();
    Customer customer = EasyMock.createStrictMock(Customer.class);
    customerList.add(customer);
    EasyMock.expect(dao.findCustomers(EasyMock.capture(capture))).andReturn(customerList);
    EasyMock.replay(dao);
    assertEquals(
        "Should have found customer.", customer, dao.findCustomerByGuid(guid, allowDeleted));
    EasyMock.verify(dao);
    assertEquals("Wrong # of constraints.", 1, capture.getValue().size());
    constraint = capture.getValue().get(0);
    assertEquals(
        "Wrong property in constraint.",
        ICustomerService.PROP_CLOUD_SERVICE_GUID,
        constraint.getProperty());
    assertEquals(
        "Wrong operator in constraint.",
        SearchConstraintOperator.CONSTRAINT_EQUALS,
        constraint.getOperator());
    assertEquals("Wrong value in constraint.", guid, constraint.getValue());
  }