package de.fred4jupiter.fredbet.service.excel;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

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

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import de.fred4jupiter.fredbet.AbstractIntegrationTest;
import de.fred4jupiter.fredbet.domain.Match;

public class ExcelImportServiceIT extends AbstractIntegrationTest {

	private static final Logger LOG = LoggerFactory.getLogger(ExcelImportServiceIT.class);

	@Autowired
	private ExcelImportService excelImportService;

	@Test
	public void readExcelFileWithMatchesToImport() {
		List<Match> matches = excelImportService.importFromExcel(new File("src/test/resources/excelimport/MatchesImportTemplate.xlsx"));
		assertNotNull(matches);
		assertFalse(matches.isEmpty());
		assertEquals(2, matches.size());

		for (Match match : matches) {
			assertNotNull(match);
			LOG.debug("match: {}", match);
		}
	}

}

@@ -259,67 +259,8 @@
 t;%0D%0A
-import org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0A
 impo
@@ -420,176 +420,227 @@
 ain.
-Match;%0D%0A%0D%0Apublic class ExcelImportServiceIT extends AbstractIntegrationTest %7B%0D%0A%0D%0A%09private static final Logger LOG = LoggerFactory.getLogger(ExcelImportServiceIT.class);
+Country;%0D%0Aimport de.fred4jupiter.fredbet.domain.Group;%0D%0Aimport de.fred4jupiter.fredbet.domain.Match;%0D%0Aimport de.fred4jupiter.fredbet.util.DateUtils;%0D%0A%0D%0Apublic class ExcelImportServiceIT extends AbstractIntegrationTest %7B
 %0D%0A%0D%0A
@@ -1000,13 +1000,8 @@
 %0D%0A%09%09
-for (
 Matc
@@ -1011,18 +1011,19 @@
 atch
- :
+1 =
  matches
 ) %7B%0D
@@ -1022,77 +1022,723 @@
 ches
-) %7B%0D%0A%09%09%09assertNotNull(match);%0D%0A%09%09%09LOG.debug(%22match: %7B%7D%22, match);%0D%0A%09%09%7D
+.get(0);%0D%0A%09%09assertEquals(Country.GERMANY, match1.getCountryOne());%0D%0A%09%09assertEquals(Country.BELGIUM, match1.getCountryTwo());%0D%0A%09%09assertEquals(Group.GROUP_B, match1.getGroup());%0D%0A%09%09assertEquals(DateUtils.parseDate(%2201.06.2017 18:00%22, %22dd.MM.yyyy HH:mm%22), match1.getKickOffDate());%0D%0A%09%09assertEquals(%22Westfalenstadion, Dortmund%22, match1.getStadium());%0D%0A%0D%0A%09%09Match match2 = matches.get(1);%0D%0A%09%09assertEquals(Country.ANDORRA, match2.getCountryOne());%0D%0A%09%09assertEquals(Country.ISRAEL, match2.getCountryTwo());%0D%0A%09%09assertEquals(Group.GROUP_E, match2.getGroup());%0D%0A%09%09assertEquals(DateUtils.parseDate(%2205.02.2018 20:00%22, %22dd.MM.yyyy HH:mm%22), match2.getKickOffDate());%0D%0A%09%09assertEquals(%22Allianz Arena, M%C3%BCnchen%22, match2.getStadium());
 %0D%0A%09%7D

update test