package de.learnlib.algorithms.angluin;

import de.learnlib.algorithms.angluin.oracles.SimpleOracle;
import de.learnlib.api.LearningAlgorithm;
import de.learnlib.api.Query;
import net.automatalib.automata.fsa.DFA;
import net.automatalib.words.Alphabet;
import net.automatalib.words.Word;
import net.automatalib.words.impl.ArrayWord;
import net.automatalib.words.impl.FastAlphabet;
import net.automatalib.words.impl.Symbol;
import net.automatalib.words.util.Words;
import org.junit.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class TestSimpleAutomaton {

	private Symbol zero;
	private Symbol one;

	private LearningAlgorithm<DFA, Symbol, Boolean> angluin;

	@BeforeClass
	public void setup() {
		Alphabet<Symbol> alphabet = new FastAlphabet<>();
		zero = new Symbol(0);
		one = new Symbol(1);

		alphabet.add(zero);
		alphabet.add(one);

		angluin = new Angluin<>(alphabet, new SimpleOracle());
	}

	@Test
	public void testFirstHypothesis() {
		angluin.startLearning();
		DFA hypothesis = angluin.getHypothesisModel();
		Assert.assertEquals(hypothesis.getStates().size(), 2);
	}

	@Test(dependsOnMethods = "testFirstHypothesis")
	public void testCounterExample() {
		Word<Symbol> counterExample = new ArrayWord<>();
		counterExample = Words.append(counterExample, one, one, zero);
		Query<Symbol, Boolean> query = new Query<>(counterExample);
		query.setOutput(false);


		angluin.refineHypothesis(query);
		DFA hypothesis = angluin.getHypothesisModel();
		Assert.assertEquals(hypothesis.getStates().size(), 4);
	}

}

@@ -953,249 +953,1017 @@
 Test
-%0A%09public void testFirstHypothesis() %7B%0A%09%09angluin.startLearning();%0A%09%09DFA hypothesis = angluin.getHypothesisModel();%0A%09%09Assert.assertEquals(hypothesis.getStates().size(), 2);%0A%09%7D%0A%0A%09@Test(dependsOnMethods = %22testFirstHypothesis%22)%0A%09public void test
+(expectedExceptions = IllegalStateException.class)%0A%09public void testGetHypothesisBeforeLearnIteration() %7B%0A%09%09angluin.getHypothesisModel();%0A%09%7D%0A%0A%09@Test(expectedExceptions = IllegalStateException.class)%0A%09public void testRefinementBeforeLearnIteration() %7B%0A%09%09angluin.refineHypothesis(createCounterExample());%0A%09%7D%0A%0A%09@Test(dependsOnMethods = %22testGetHypothesisBeforeLearnIteration%22)%0A%09public void testFirstHypothesis() %7B%0A%09%09angluin.startLearning();%0A%09%09DFA hypothesis = angluin.getHypothesisModel();%0A%09%09Assert.assertEquals(hypothesis.getStates().size(), 2);%0A%09%7D%0A%0A%09@Test(dependsOnMethods = %22testFirstHypothesis%22, expectedExceptions = IllegalStateException.class)%0A%09public void testDuplicateLearnInvocation() %7B%0A%09%09angluin.startLearning();%0A%09%7D%0A%0A%09@Test(dependsOnMethods = %22testFirstHypothesis%22)%0A%09public void testCounterExample() %7B%0A%09%09angluin.refineHypothesis(createCounterExample());%0A%09%09DFA hypothesis = angluin.getHypothesisModel();%0A%09%09Assert.assertEquals(hypothesis.getStates().size(), 4);%0A%09%7D%0A%0A%09private Query%3CSymbol, Boolean%3E create
 Coun
@@ -2185,153 +2185,27 @@
 e);%0A
-%0A%0A%09%09angluin.refineHypothesis(query);%0A%09%09DFA hypothesis = angluin.getHypothesisModel();%0A%09%09Assert.assertEquals(hypothesis.getStates().size(), 4)
+%09%09return query
 ;%0A%09%7D%0A%0A
+%0A
 %7D%0A

Test internal state as specified by Javadoc