package pt.fccn.mobile.arquivo.tests.pagesearch;

import static org.junit.Assert.assertTrue;

import java.time.LocalDate;

import org.junit.Test;
import org.openqa.selenium.By;

import pt.fccn.arquivo.selenium.Retry;
import pt.fccn.arquivo.selenium.WebDriverTestBaseParalell;
import pt.fccn.mobile.arquivo.utils.IonicDatePicker;

/**
 * 
 * @author pedro.gomes.fccn@gmail.com
 *
 */

public class PageSearchOverlapDatesTest extends WebDriverTestBaseParalell {

	public PageSearchOverlapDatesTest(String os, String version, String browser, String deviceName,
			String deviceOrientation) {
		super(os, version, browser, deviceName, deviceOrientation);
	}
	@Test
	@Retry
	public void pageSearchOverlapDatesTest() throws Exception {
		run("Search FCCN term", () -> {
			driver.findElement(By.id("txtSearch")).clear();
			driver.findElement(By.id("txtSearch")).sendKeys("fccn");
			driver.findElement(By.xpath("//*[@id=\"buttonSearch\"]/button")).click();
		});
		
		run("Open from date picker", () -> waitUntilElementIsVisibleAndGet(By.id("sliderCircleLeft")).click());
		LocalDate fromDate = LocalDate.of(1997, 5, 20);
		run("Insert " + fromDate.toString() + " on start date picker",
				() -> IonicDatePicker.changeTo(driver, fromDate));

		run("Open until date picker", () -> waitUntilElementIsVisibleAndGet(By.id("sliderCircleRight")).click());
		LocalDate untilDate = LocalDate.of(1996, 8, 22);
						
		appendError(() -> {
			assertTrue("Check if it is possible to do date overlap: ", checkDatePicker(untilDate));
		});

	}

	private boolean checkDatePicker(LocalDate untilDate) {
		try{
			IonicDatePicker.changeTo(driver, untilDate);
			return false;
		} catch (Exception e){
			return true;
		}
	}

}

@@ -647,16 +647,17 @@
 on);%0A%09%7D%0A
+%0A
 %09@Test%0A%09
@@ -952,19 +952,17 @@
 ;%0A%09%09%7D);%0A
-%09%09
 %0A
+
 %09%09run(%22O
@@ -1393,15 +1393,9 @@
 2);%0A
-%09%09%09%09%09%09
 %0A
+
 %09%09ap
@@ -1575,16 +1575,17 @@
  %7B%0A%09%09try
+ 
 %7B%0A%09%09%09Ion
@@ -1643,16 +1643,16 @@
  false;%0A
-
 %09%09%7D catc
@@ -1666,16 +1666,17 @@
 ption e)
+ 
 %7B%0A%09%09%09ret

Fix Format