TTT extends AbstractLearningAlgorithm<String, String> implements Serializable { @Override public String getInternalData(LearningAlgorithm.MealyLearner<String, String> learner) { if (!(learner instanceof TTTLearnerMealy)) { throw new IllegalArgumentException("Can not read the internal data because the algorithm types" + "were different"); } TTTLearnerMealy<String, String> tttLearner = (TTTLearnerMealy<String, String>) learner; return toJSON(tttLearner.getDiscriminationTree()); }  @Override LearningAlgorithm.MealyLearner<String, String> createLearner(Alphabet<String> sigma,
            MembershipOracle<String, Word<String>> oracle); @Override String getInternalData(LearningAlgorithm.MealyLearner<String, String> learner); @Override void resume(LearningAlgorithm.MealyLearner<String, String> learner, byte[] data);  }
@Test public void shouldReturnCorrectInternalData() { TTTLearnerMealy learner = createLearnerMock(); String json = algorithm.getInternalData(learner); assertEquals("{\"discriminator\": \"null\", \"children\": []}", json); }
@Test(expected = IllegalArgumentException.class) public void shouldFailToCreateInternalDataFromWrongAlgorithmType() { LearningAlgorithm.MealyLearner learner = mock(LearningAlgorithm.MealyLearner.class); algorithm.getInternalData(learner); }