예제 #1
0
  @Test
  public void test_equals_and_hashcode() throws Exception {
    WorkDuration duration = WorkDuration.createFromLong(28800, HOURS_IN_DAY);
    WorkDuration durationWithSameValue = WorkDuration.createFromLong(28800, HOURS_IN_DAY);
    WorkDuration durationWithDifferentValue = WorkDuration.createFromLong(14400, HOURS_IN_DAY);

    assertThat(duration).isEqualTo(duration);
    assertThat(durationWithSameValue).isEqualTo(duration);
    assertThat(durationWithDifferentValue).isNotEqualTo(duration);
    assertThat(duration).isNotEqualTo(null);

    assertThat(duration.hashCode()).isEqualTo(duration.hashCode());
    assertThat(durationWithSameValue.hashCode()).isEqualTo(duration.hashCode());
    assertThat(durationWithDifferentValue.hashCode()).isNotEqualTo(duration.hashCode());
  }
예제 #2
0
  @Test
  public void create_from_working_long() {
    // 1 minute
    WorkDuration workDuration = WorkDuration.createFromLong(1L, HOURS_IN_DAY);
    assertThat(workDuration.days()).isEqualTo(0);
    assertThat(workDuration.hours()).isEqualTo(0);
    assertThat(workDuration.minutes()).isEqualTo(1);

    // 1 hour
    workDuration = WorkDuration.createFromLong(100L, HOURS_IN_DAY);
    assertThat(workDuration.days()).isEqualTo(0);
    assertThat(workDuration.hours()).isEqualTo(1);
    assertThat(workDuration.minutes()).isEqualTo(0);

    // 1 day
    workDuration = WorkDuration.createFromLong(10000L, HOURS_IN_DAY);
    assertThat(workDuration.days()).isEqualTo(1);
    assertThat(workDuration.hours()).isEqualTo(0);
    assertThat(workDuration.minutes()).isEqualTo(0);
  }
예제 #3
0
 @Test
 public void test_toString() throws Exception {
   assertThat(WorkDuration.createFromLong(28800, HOURS_IN_DAY).toString()).isNotNull();
 }