package nl.loxia.optimalisatie.api;

import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.junit.Before;
import org.junit.Test;

public class SetCoverProblemTest {

	private final Map<Swod, List<String>> swodNaarMeldingen = new HashMap<Swod, List<String>>();

	@Before
	public void before() {
		swodNaarMeldingen.put(new Swod("A", 1), asList("AAA-001", "AAA-002"));
		swodNaarMeldingen.put(new Swod("B", 3), asList("AAA-001", "AAA-003"));
	}

	@Test
	public void getSwods() {
		SetCoverProblem setCoverProblem = new SetCoverProblem(swodNaarMeldingen);

		Set<Swod> expected = new HashSet<Swod>(asList(new Swod("A", 1),
				new Swod("B", 3)));
		assertThat(setCoverProblem.getSwods(), is(expected));
	}

	@Test
	public void getMeldingen() {
		SetCoverProblem setCoverProblem = new SetCoverProblem(swodNaarMeldingen);

		Set<String> expected = new HashSet<String>(asList("AAA-001", "AAA-002",
				"AAA-003"));
		assertThat(setCoverProblem.getMeldingen(), is(expected));
	}

	@Test
	public void isSolution() {
		Set<Swod> swods = swodNaarMeldingen.keySet();
		SetCoverSolution solution = new SetCoverSolution(swods);

		SetCoverProblem setCoverProblem = new SetCoverProblem(swodNaarMeldingen);

		assertThat(setCoverProblem.isSolution(solution), is(true));

	}

}

@@ -1461,15 +1461,329 @@
 true));%0A
+%09%7D%0A%0A%09@Test%0A%09public void isNotASolution() %7B%0A%09%09Set%3CSwod%3E swods = new HashSet%3CSwod%3E();%0A%09%09swods.add(new Swod(%22A%22, 1));%0A%09%09SetCoverSolution solution = new SetCoverSolution(swods);%0A%0A%09%09SetCoverProblem setCoverProblem = new SetCoverProblem(swodNaarMeldingen);%0A%0A%09%09assertThat(setCoverProblem.isSolution(solution), is(false));
 %0A%09%7D%0A%0A%7D%0A

test coverage verbeterd