package de.wellnerbou.chronic.replay;

import org.fest.assertions.api.Assertions;
import org.joda.time.DateTime;
import org.junit.Test;

public class LogReplayReaderTest {

	private final LogReplayReader logReplayReader = new LogReplayReader(null, null, null);

	@Test
	public void calculateStarttimeRelativeToLogs_fromOptionBeforeLogfileStart_shouldReturnLogfileStart() {
		DateTime fromOptionGiven = new DateTime(1970, 1, 1, 10, 50, 12);
		DateTime firstLogfileTime = new DateTime(2014, 1, 2, 11, 50, 12);
		LogLineData logLineData = new LogLineData();
		logLineData.setTime(firstLogfileTime.getMillis());

		final long result = logReplayReader.calculateStarttimeRelativeToLogs(fromOptionGiven, logLineData);
		Assertions.assertThat(result).isEqualTo(firstLogfileTime.getMillis());
	}

	@Test
	public void calculateStarttimeRelativeToLogs_fromOptionAfterLogfileStart_shouldReturnFromOption() {
		DateTime fromOptionGiven = new DateTime(1970, 1, 1, 11, 50, 12);
		DateTime firstLogfileTime = new DateTime(2014, 1, 2, 10, 50, 12);
		LogLineData logLineData = new LogLineData();
		logLineData.setTime(firstLogfileTime.getMillis());

		final long result = logReplayReader.calculateStarttimeRelativeToLogs(fromOptionGiven, logLineData);
		Assertions.assertThat(result).isEqualTo(fromOptionGiven.getMillis());
	}

	@Test
	public void testIsInTimeRange() {
		final DateTime from = new DateTime(39300000);
		final long lineDataTime = 1388660111000L;
		LogLineData logLineData = new LogLineData();
		logLineData.setTime(lineDataTime);

		Assertions.assertThat(logReplayReader.isInTimeRange(from, from.plusSeconds(1), logLineData)).isFalse();
	}
}

@@ -1243,38 +1243,69 @@
 ions.assertThat(
-result
+new DateTime(result).getMillisOfDay()
 ).isEqualTo(from
@@ -1317,32 +1317,37 @@
 nGiven.getMillis
+OfDay
 ());%0A%09%7D%0A%0A%09@Test%0A

Fix test