<commit_before>package org.slc.sli.dal.repository;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slc.sli.domain.Entity;
import org.slc.sli.domain.MongoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/spring/mongodbContext.xml" })
public class EntityRepositoryTest {

	@Autowired
	private EntityRepository repository;

	// TODO - needs Mongo instance installed on Jenkins.
	@Test
	@Ignore(value = "We need to configure mongod on the build server,comment it out to run on local mongodb")
	public void testCRUDEntityRepository() {
		
		//clean up the existing student data
		repository.deleteAll("student");

		// create new student entity
		Entity student = buildTestStudentEntity();

		// test save
		Entity saved = repository.create(student);
		String id = saved.getId();
		assertTrue(!id.equals(""));

		// test findAll
		Iterable<Entity> entities = repository.findAll("student",1,20);
		assertNotNull(entities);
		Entity found = entities.iterator().next();
		assertEquals(found.getBody().get("birthDate"),
				student.getBody().get("birthDate"));
		assertEquals((found.getBody()).get("firstName"), "Jane");
		assertEquals((found.getBody()).get("lastName"), "Doe");

		// test find by id
		Entity foundOne = repository.find("student", saved.getId());
		assertNotNull(foundOne);
		assertEquals(foundOne.getBody().get("birthDate"), student.getBody()
				.get("birthDate"));
		assertEquals((found.getBody()).get("firstName"), "Jane");

		// test update
		found.getBody().put("firstName", "Mandy");
		repository.update(found);
		entities = repository.findAll("student",1,20);
		assertNotNull(entities);
		Entity updated = entities.iterator().next();
		assertEquals(updated.getBody().get("firstName"), "Mandy");

		// test delete by id
		Entity student2 = buildTestStudentEntity();
		student2 = repository.create(student2);
		entities = repository.findAll("student",1,20);
		student = entities.iterator().next();
		assertNotNull(entities.iterator().next());
		repository.delete("student", student2.getId());
		entities = repository.findAll("student",1,20);
		entities.iterator().next();
		assertFalse(entities.iterator().hasNext());

		// test deleteAll by entity type
		repository.delete(student);
		entities = repository.findAll("student",1,20);
		assertFalse(entities.iterator().hasNext());
		
	}

	private Entity buildTestStudentEntity() {
		
		Map<String, Object> body = new HashMap<String, Object>();
		body.put("firstName", "Jane");
		body.put("lastName", "Doe");
		Date birthDate = new Timestamp(23234000);
		body.put("birthDate", birthDate);
		body.put("cityOfBirth", "Chicago");
		body.put("CountyOfBirth", "US");
		body.put("dateEnteredUs", birthDate);
		body.put("displacementStatus", "some");
		body.put("economicDisadvantaged", true);
		body.put("generationCodeSuffix", "Z");
		body.put("hispanicLatinoEthnicity", true);
		body.put("limitedEnglishProficiency", "Yes");
		body.put("maidenName", "Smith");
		body.put("middleName", "Patricia");
		body.put("multipleBirthStatus", true);
		body.put("oldEthnicity", "AMERICAN_INDIAN_OR_ALASKAN_NATIVE");
		body.put("personalInformationVerification", "verified");
		body.put("personalTitlePrefix", "Miss");
		body.put("profileThumbnail", "doej23.png");
		body.put("schoolFoodServicesEligibility", "REDUCED_PRICE");
		body.put("sex", "Female");
		body.put("stateOfBirthAbbreviation", "IL");
		body.put("studentSchoolId", "DOE-JANE-222");
		Entity student = new MongoEntity("student", null,body,null);
		return student;
	}

}
<commit_msg>flesh out unit test for mongo entity repository for student entity<commit_after>package org.slc.sli.dal.repository;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slc.sli.domain.Entity;
import org.slc.sli.domain.MongoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/spring/mongodbContext.xml" })
public class EntityRepositoryTest {

	@Autowired
	private EntityRepository repository;

	// TODO - needs Mongo instance installed on Jenkins.
	@Test
	@Ignore(value = "We need to configure mongod on the build server,comment it out to run on local mongodb")
	public void testCRUDEntityRepository() {
		
		//clean up the existing student data
		repository.deleteAll("student");

		// create new student entity
		Entity student = buildTestStudentEntity();

		// test save
		Entity saved = repository.create(student);
		String id = saved.getId();
		assertTrue(!id.equals(""));

		// test findAll
		Iterable<Entity> entities = repository.findAll("student",0,20);
		assertNotNull(entities);
		Entity found = entities.iterator().next();
		assertEquals(found.getBody().get("birthDate"),
				student.getBody().get("birthDate"));
		assertEquals((found.getBody()).get("firstName"), "Jane");
		assertEquals((found.getBody()).get("lastName"), "Doe");

		// test find by id
		Entity foundOne = repository.find("student", saved.getId());
		assertNotNull(foundOne);
		assertEquals(foundOne.getBody().get("birthDate"), student.getBody()
				.get("birthDate"));
		assertEquals((found.getBody()).get("firstName"), "Jane");

		// test update
		found.getBody().put("firstName", "Mandy");
		repository.update(found);
		entities = repository.findAll("student",0,20);
		assertNotNull(entities);
		Entity updated = entities.iterator().next();
		assertEquals(updated.getBody().get("firstName"), "Mandy");

		// test delete by id
		Entity student2 = buildTestStudentEntity();
		student2 = repository.create(student2);
		entities = repository.findAll("student",0,20);
		student = entities.iterator().next();
		assertNotNull(entities.iterator().next());
		repository.delete("student", student2.getId());
		student2 = repository.find("student",student2.getId());
		assertNull(student2);

		// test deleteAll by entity type
		repository.deleteAll("student");
		entities = repository.findAll("student",0,20);
		assertFalse(entities.iterator().hasNext());
	
	}

	private Entity buildTestStudentEntity() {
		
		Map<String, Object> body = new HashMap<String, Object>();
		body.put("firstName", "Jane");
		body.put("lastName", "Doe");
		Date birthDate = new Timestamp(23234000);
		body.put("birthDate", birthDate);
		body.put("cityOfBirth", "Chicago");
		body.put("CountyOfBirth", "US");
		body.put("dateEnteredUs", birthDate);
		body.put("displacementStatus", "some");
		body.put("economicDisadvantaged", true);
		body.put("generationCodeSuffix", "Z");
		body.put("hispanicLatinoEthnicity", true);
		body.put("limitedEnglishProficiency", "Yes");
		body.put("maidenName", "Smith");
		body.put("middleName", "Patricia");
		body.put("multipleBirthStatus", true);
		body.put("oldEthnicity", "AMERICAN_INDIAN_OR_ALASKAN_NATIVE");
		body.put("personalInformationVerification", "verified");
		body.put("personalTitlePrefix", "Miss");
		body.put("profileThumbnail", "doej23.png");
		body.put("schoolFoodServicesEligibility", "REDUCED_PRICE");
		body.put("sex", "Female");
		body.put("stateOfBirthAbbreviation", "IL");
		body.put("studentSchoolId", "DOE-JANE-222");
		Entity student = new MongoEntity("student", null,body,null);
		return student;
	}

}

{'fraction_non_alphanumeric': 0.15135711745881236, 'fraction_numerical': 0.008296787957804906, 'mean_word_length': 4.8434903047091415, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '538072', 'n_tokens_mistral': 2788, 'n_tokens_neox': 2520, 'n_words': 484}