コード例 #1
0
  @Test
  public void shouldAddAndRetrieveLogsBySubjectAndParameter() {

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("key1", "value1");
    parameters.put("key2", "value2");

    CouchEventLog couchLog = new CouchEventLog();
    couchLog.setSubject("org.motechproject.test");
    couchLog.setParameters(parameters);

    CouchEventLog couchLog2 = new CouchEventLog();
    couchLog2.setSubject("org.motechproject.test2");
    couchLog2.setParameters(parameters);

    allCouchLogs.log(couchLog);
    allCouchLogs.log(couchLog2);

    List<CouchEventLog> logList =
        allCouchLogs.findAllBySubjectAndParameter("org.motechproject.test", "key1", "value1");
    assertEquals(
        asList("org.motechproject.test"), extract(logList, on(CouchEventLog.class).getSubject()));

    logList =
        allCouchLogs.findAllBySubjectAndParameter("org.motechproject.test2", "key1", "value1");
    assertEquals(
        asList("org.motechproject.test2"), extract(logList, on(CouchEventLog.class).getSubject()));
  }
コード例 #2
0
  @Test
  public void shouldAddAndRetrieveLogsBySubject() {

    CouchEventLog couchLog = new CouchEventLog();
    couchLog.setSubject("org.motechproject.test");

    CouchEventLog couchLog2 = new CouchEventLog();
    couchLog2.setSubject("org.motechproject.test2");

    allCouchLogs.log(couchLog);
    allCouchLogs.log(couchLog2);

    List<CouchEventLog> logList = allCouchLogs.findAllBySubject("org.motechproject.test");
    assertEquals(
        asList("org.motechproject.test"), extract(logList, on(CouchEventLog.class).getSubject()));

    logList = allCouchLogs.findAllBySubject("org.motechproject.test2");

    assertEquals(
        asList("org.motechproject.test2"), extract(logList, on(CouchEventLog.class).getSubject()));
    ;
  }