<commit_before>package nl.fixx.asset.data.test;

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

import org.junit.After;
import org.junit.Before;
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;

import nl.fixx.asset.data.config.MongoConfiguration;
import nl.fixx.asset.data.domain.Resource;
import nl.fixx.asset.data.repository.ResourceRepository;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { MongoConfiguration.class })
public class TestResourceRepository {

    @Autowired
    ResourceRepository repository;

    @Before
    public void init() {
	saveTest();
    }

    @Test
    public void saveTest() {
	Resource resource = new Resource();
	resource.setContactNumber("0644010101");
	resource.setEmail("<EMAIL>");
	resource.setFirstName("Courage");
	resource.setSurname("Cowardly Dog");

	Resource resourceRet = this.repository.save(resource);

	assertNotNull(resourceRet.getId());
    }
    
    @Test
    public void updateTest(){
	Resource resource = this.repository.findByEmail("<EMAIL>");
	String id = resource.getId();
	assertNotNull(resource);

	//update
	resource.setSurname("Uber Dog");
	this.repository.save(resource);
	assertSame(id, resource.getId());
	assertSame("Uber Dog", resource.getSurname());
	
	//restore
	resource.setSurname("Cowardly Dog");
	this.repository.save(resource);
	assertSame(id, resource.getId());
	assertSame("Cowardly Dog", resource.getSurname());
    }

    @Test
    public void findByIdEmailTest() {
	// first find without id
	Resource resource = this.repository.findByEmail("<EMAIL>");
	assertNotNull(resource);

	resource = this.repository.findById(resource.getId());
	assertEquals("0644010101", resource.getContactNumber());
	assertEquals("<EMAIL>", resource.getEmail());
	assertEquals("Courage", resource.getFirstName());
	assertEquals("Cowardly Dog", resource.getSurname());
    }

    @Test
    public void deleteTest() {<commit_msg>minor update<commit_after>package nl.fixx.asset.data.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;

import org.junit.After;
import org.junit.Before;
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;

import nl.fixx.asset.data.config.MongoConfiguration;
import nl.fixx.asset.data.domain.Resource;
import nl.fixx.asset.data.repository.ResourceRepository;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { MongoConfiguration.class })
public class TestResourceRepository {

    @Autowired
    ResourceRepository repository;

    @Before
    public void init() {
	saveTest();
    }

    @Test
    public void saveTest() {
	Resource resource = new Resource();
	resource.setContactNumber("0644010101");
	resource.setEmail("<EMAIL>");
	resource.setFirstName("Courage");
	resource.setSurname("Cowardly Dog");

	Resource resourceRet = this.repository.save(resource);

	assertNotNull(resourceRet.getId());
    }
    
    @Test
    public void updateTest(){
	Resource resource = this.repository.findByEmail("<EMAIL>");
	String id = resource.getId();
	assertNotNull(resource);

	//update
	resource.setSurname("Uber Dog");
	resource = this.repository.save(resource);
	assertSame(id, resource.getId());
	assertSame("Uber Dog", resource.getSurname());
	
	//restore
	resource.setSurname("Cowardly Dog");
	resource = this.repository.save(resource);
	assertSame(id, resource.getId());
	assertSame("Cowardly Dog", resource.getSurname());
    }

    @Test
    public void findByIdEmailTest() {
	// first find without id
	Resource resource = this.repository.findByEmail("<EMAIL>");
	assertNotNull(resource);

	resource = this.repository.findById(resource.getId());
	assertEquals("0644010101", resource.getContactNumber());
	assertEquals("<EMAIL>", resource.getEmail());
	assertEquals("Courage", resource.getFirstName());
	assertEquals("Cowardly Dog", resource.getSurname());
    }

    @Test
    public void deleteTest() {
{'fraction_non_alphanumeric': 0.12999560825647782, 'fraction_numerical': 0.010101010101010102, 'mean_word_length': 5.525787965616046, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4555329', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1335, 'n_words': 248}