package eu.dnetlib.data.mdstore;

import static org.junit.Assert.*;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * test mock mdstore dao.
 *
 * @author marko
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "MDStoreServiceMockImplTest-context.xml")
public class MockMDStoreDaoTest {

	/**
	 * logger.
	 */
	private static final Log log = LogFactory.getLog(MockMDStoreDaoTest.class); // NOPMD by marko on 11/24/08 5:02 PM

	/**
	 * num mdstores.
	 */
	static final int NUM_MDSTORES = 2;

	/**
	 * instance under test.
	 */
	@Autowired
	private transient MockMDStoreDao dao;

	/**
	 * test dao.
	 *
	 * @throws MDStoreServiceException shouldn't happen
	 */
	@Test
	public void testDao() throws MDStoreServiceException {
		assertEquals("size", NUM_MDSTORES, dao.listMDStores().size());

		MDStore mdstore = dao.getMDStore(dao.listMDStores().get(0));
		assertNotNull("mdstore", mdstore);

		assertEquals(2, mdstore.getSize());

		assertNotNull("content", mdstore.getRecord(1));

		log.debug(mdstore.getRecord(1));
	}

}
