/*
 * Copyright (c) 2013 mgm technology partners GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mgmtp.perfload.perfalyzer.base.marker;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.testng.annotations.Test;

import com.mgmtp.perfload.perfalyzer.util.Marker;
import com.mgmtp.perfload.perfalyzer.util.MarkersReader;

/**
 * @author ctchinda
 */
public class MarkersReaderTest {

	@Test
	public void testMarkersCreated() throws IOException {

		MarkersReader markerReader = new MarkersReader(new File("src/test/resources/markers/test.perfload"));

		List<Marker> result = markerReader.readMarkers();

		Marker marker1 = result.get(0);
		assertThat(marker1.getName(), is(equalTo("Marker 1")));
		assertThat(marker1.getLeftMillis(), is(equalTo(600000L)));
		assertThat(marker1.getRightMillis(), is(equalTo(900000L)));

		Marker marker3 = result.get(1);
		assertThat(marker3.getName(), is(equalTo("Marker 3")));
		assertThat(marker3.getLeftMillis(), is(equalTo(1300000L)));
		assertThat(marker3.getRightMillis(), is(equalTo(1400000L)));

		Marker marker2 = result.get(2);
		assertThat(marker2.getName(), is(equalTo("Marker 2")));
		assertThat(marker2.getLeftMillis(), is(equalTo(700000L)));
		assertThat(marker2.getRightMillis(), is(equalTo(1000000L)));

		Marker marker4 = result.get(3);
		assertThat(marker4.getName(), is(equalTo("Marker 4")));
		assertThat(marker4.getLeftMillis(), is(equalTo(370000L)));
		assertThat(marker4.getRightMillis(), is(equalTo(1700000L)));
	}
}

@@ -661,16 +661,76 @@
 arker;%0A%0A
+import static com.google.common.collect.Lists.newArrayList;%0A
 import s
@@ -909,16 +909,75 @@
 eption;%0A
+import java.util.Collections;%0Aimport java.util.Comparator;%0A
 import j
@@ -1391,16 +1391,29 @@
 esult = 
+newArrayList(
 markerRe
@@ -1430,16 +1430,202 @@
 arkers()
+);%0A%09%09Collections.sort(result, new Comparator%3CMarker%3E() %7B%0A%09%09%09@Override%0A%09%09%09public int compare(final Marker o1, final Marker o2) %7B%0A%09%09%09%09return o1.getName().compareTo(o2.getName());%0A%09%09%09%7D%0A%09%09%7D)
 ;%0A%0A%09%09Mar
@@ -1850,17 +1850,17 @@
 r marker
-3
+2
  = resul
@@ -1884,25 +1884,25 @@
 tThat(marker
-3
+2
 .getName(), 
@@ -1920,17 +1920,17 @@
 %22Marker 
-3
+2
 %22)));%0A%09%09
@@ -1942,25 +1942,25 @@
 tThat(marker
-3
+2
 .getLeftMill
@@ -1976,18 +1976,17 @@
 equalTo(
-13
+7
 00000L))
@@ -2007,17 +2007,17 @@
 t(marker
-3
+2
 .getRigh
@@ -2039,17 +2039,17 @@
 qualTo(1
-4
+0
 00000L))
@@ -2059,33 +2059,33 @@
 %0A%09%09Marker marker
-2
+3
  = result.get(2)
@@ -2097,33 +2097,33 @@
 ssertThat(marker
-2
+3
 .getName(), is(e
@@ -2129,33 +2129,33 @@
 equalTo(%22Marker 
-2
+3
 %22)));%0A%09%09assertTh
@@ -2155,33 +2155,33 @@
 ssertThat(marker
-2
+3
 .getLeftMillis()
@@ -2185,33 +2185,34 @@
 s(), is(equalTo(
-7
+13
 00000L)));%0A%09%09ass
@@ -2217,33 +2217,33 @@
 ssertThat(marker
-2
+3
 .getRightMillis(
@@ -2249,33 +2249,33 @@
 (), is(equalTo(1
-0
+4
 00000L)));%0A%0A%09%09Ma

Fix unit test