<commit_before>package stsc.storage;

import java.util.Date;

import org.joda.time.LocalDate;
import org.junit.Assert;
import org.junit.Test;

import stsc.common.BadSignalException;
import stsc.common.signals.EodSignal;
import stsc.common.signals.Signal;
import stsc.common.storage.SignalsStorage;
import stsc.signals.series.CommonSignalsSerie;

public class SignalsStorageTest {

	static public class TestSignal extends EodSignal {
		public final int id;

		public TestSignal(int id) {
			this.id = id;
		}
	}

	@Test
	public void testSignalsStorage() throws BadSignalException {
		SignalsStorage signalsStorage = new SignalsStorageImpl();
		signalsStorage.registerEodAlgorithmSerie("e1", new CommonSignalsSerie<EodSignal>(TestSignal.class));
		final Date d = new LocalDate(2010, 10, 20).toDate();
		signalsStorage.addEodSignal("e1", d, new TestSignal(12));
		final Signal<? extends EodSignal> ts = signalsStorage.getEodSignal("e1", d);
		Assert.assertEquals(12, ts.getSignal(TestSignal.class).id);
		Assert.assertEquals(0, ts.getIndex());
		Assert.assertEquals(d, ts.getDate());
	}

	@Test
	public void testSignalsStorageGetByIndex() throws BadSignalException {
		SignalsStorage signalsStorage = new SignalsStorageImpl();
		signalsStorage.registerEodAlgorithmSerie("e1", new CommonSignalsSerie<EodSignal>(TestSignal.class));

		final LocalDate d = new LocalDate(2010, 10, 20);
		signalsStorage.addEodSignal("e1", d.toDate(), new TestSignal(12));
		signalsStorage.addEodSignal("e1", d.plusDays(1).toDate(), new TestSignal(15));
		signalsStorage.addEodSignal("e1", d.plusDays(2).toDate(), new TestSignal(13));
		signalsStorage.addEodSignal("e1", d.plusDays(3).toDate(), new TestSignal(14));

		boolean exception = false;
		try {
			signalsStorage.addEodSignal("e2", d.plusDays(100).toDate(), new TestSignal(100));
		} catch (BadSignalException e) {
			exception = true;
		}
		Assert.assertTrue(exception);

		Assert.assertEquals(12, signalsStorage.getEodSignal("e1", 0).getSignal(TestSignal.class).id);
		Assert.assertEquals(13, signalsStorage.getEodSignal("e1", 2).getSignal(TestSignal.class).id);
		Assert.assertEquals(15, signalsStorage.getEodSignal("e1", 1).getSignal(TestSignal.class).id);
		Assert.assertEquals(14, signalsStorage.getEodSignal("e1", 3).getSignal(TestSignal.class).id);
	}
}<commit_msg>#44 renamed TestSignal to TestEodSignal<commit_after>package stsc.storage;

import java.util.Date;

import org.joda.time.LocalDate;
import org.junit.Assert;
import org.junit.Test;

import stsc.common.BadSignalException;
import stsc.common.signals.EodSignal;
import stsc.common.signals.Signal;
import stsc.common.storage.SignalsStorage;
import stsc.signals.series.CommonSignalsSerie;

public class SignalsStorageTest {

	static public class TestEodSignal extends EodSignal {
		public final int id;

		public TestEodSignal(int id) {
			this.id = id;
		}
	}

	@Test
	public void testSignalsStorage() throws BadSignalException {
		SignalsStorage signalsStorage = new SignalsStorageImpl();
		signalsStorage.registerEodAlgorithmSerie("e1", new CommonSignalsSerie<EodSignal>(TestEodSignal.class));
		final Date d = new LocalDate(2010, 10, 20).toDate();
		signalsStorage.addEodSignal("e1", d, new TestEodSignal(12));
		final Signal<? extends EodSignal> ts = signalsStorage.getEodSignal("e1", d);
		Assert.assertEquals(12, ts.getSignal(TestEodSignal.class).id);
		Assert.assertEquals(0, ts.getIndex());
		Assert.assertEquals(d, ts.getDate());
	}

	@Test
	public void testSignalsStorageGetByIndex() throws BadSignalException {
		SignalsStorage signalsStorage = new SignalsStorageImpl();
		signalsStorage.registerEodAlgorithmSerie("e1", new CommonSignalsSerie<EodSignal>(TestEodSignal.class));

		final LocalDate d = new LocalDate(2010, 10, 20);
		signalsStorage.addEodSignal("e1", d.toDate(), new TestEodSignal(12));
		signalsStorage.addEodSignal("e1", d.plusDays(1).toDate(), new TestEodSignal(15));
		signalsStorage.addEodSignal("e1", d.plusDays(2).toDate(), new TestEodSignal(13));
		signalsStorage.addEodSignal("e1", d.plusDays(3).toDate(), new TestEodSignal(14));

		boolean exception = false;
		try {
			signalsStorage.addEodSignal("e2", d.plusDays(100).toDate(), new TestEodSignal(100));
		} catch (BadSignalException e) {
			exception = true;
		}
		Assert.assertTrue(exception);

		Assert.assertEquals(12, signalsStorage.getEodSignal("e1", 0).getSignal(TestEodSignal.class).id);
		Assert.assertEquals(13, signalsStorage.getEodSignal("e1", 2).getSignal(TestEodSignal.class).id);
		Assert.assertEquals(15, signalsStorage.getEodSignal("e1", 1).getSignal(TestEodSignal.class).id);
		Assert.assertEquals(14, signalsStorage.getEodSignal("e1", 3).getSignal(TestEodSignal.class).id);
	}
}
{'fraction_non_alphanumeric': 0.13169690501600853, 'fraction_numerical': 0.027321237993596585, 'mean_word_length': 6.379527559055118, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4153205', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1534, 'n_words': 278}