Package org.sonar.core.activity.db

Examples of org.sonar.core.activity.db.ActivityDto


  }

  @Test
  public void fail_insert_missing_type() {
    String testValue = "hello world";
    ActivityDto log = ActivityDto.createFor(testValue);
    try {
      dao.insert(session, log);
    } catch (IllegalArgumentException e) {
      assertThat(e.getMessage()).isEqualTo("Type must be set");
    }
View Full Code Here



  @Test
  public void fail_insert_missing_author() {
    String testValue = "hello world";
    ActivityDto log = ActivityDto.createFor(testValue)
      .setType(Activity.Type.QPROFILE);
    try {
      dao.insert(session, log);
    } catch (IllegalArgumentException e) {
      assertThat(e.getMessage()).isEqualTo("Type must be set");
View Full Code Here

  }

  @Test
  public void insert_text_log() {
    String testValue = "hello world";
    ActivityDto log = ActivityDto.createFor(testValue)
      .setType(Activity.Type.QPROFILE)
      .setAuthor("jUnit");
    dao.insert(session, log);

    ActivityDto newDto = Iterables.getFirst(dao.findAll(session), null);
    assertThat(newDto).isNotNull();
    assertThat(newDto.getAuthor()).isEqualTo(log.getAuthor());
    assertThat(newDto.getMessage()).isEqualTo(testValue);
  }
View Full Code Here

  @Test
  public void insert_loggable_log() {
    final String testKey = "message";
    final String testValue = "hello world";
    ActivityDto log = ActivityDto.createFor(new ActivityLog() {

      @Override
      public Map<String, String> getDetails() {
        return ImmutableMap.of(testKey, testValue);
      }

      @Override
      public String getAction() {
        return "myAction";
      }
    })
      .setAuthor("jUnit")
      .setType(Activity.Type.QPROFILE);

    dao.insert(session, log);

    ActivityDto newDto = Iterables.getFirst(dao.findAll(session), null);
    assertThat(newDto).isNotNull();
    assertThat(newDto.getAuthor()).isEqualTo(log.getAuthor());
    assertThat(newDto.getData()).isNotNull();
    Map<String, String> details = KeyValueFormat.parse(newDto.getData());
    assertThat(details.get(testKey)).isEqualTo(testValue);
  }
View Full Code Here

  @Test
  public void filter_by_date() throws InterruptedException {

    DateTime t0 = new DateTime().minusHours(1);
    ActivityDto activity = getActivityDto();
    activity.setCreatedAt(t0.toDate());
    dao.insert(dbSession, activity);
    activity = getActivityDto();
    activity.setCreatedAt(t0.toDate());
    dao.insert(dbSession, activity);
    dbSession.commit();
    DateTime t1 = new DateTime();
    activity = getActivityDto();
    activity.setCreatedAt(t1.toDate());
    dao.insert(dbSession, activity);
    dbSession.commit();
    DateTime t2 = new DateTime().plusHours(1);

    assertThat(service.search(new ActivityQuery(),
View Full Code Here

      saveActiveRuleChange(session, ruleChange, currentAuthor, currentTimeStamp);
    }
  }

  private void saveActiveRuleChange(DbSession session, ActiveRuleChange ruleChange, String author, Date currentTimeStamp) {
    ActivityDto activity = ActivityDto.createFor(ruleChange);
    activity.setType(Activity.Type.QPROFILE);
    activity.setAuthor(author);
    activity.setCreatedAt(currentTimeStamp);
    dao.insert(session, activity);
  }
View Full Code Here

TOP

Related Classes of org.sonar.core.activity.db.ActivityDto

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.