<commit_before>/* Copyright 2015 Roychoudhury, Abhishek */

package test.codeavengers.main.data.jpa.impl;

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

import java.util.List;

import org.codeavengers.common.dto.entity.Category;
import org.codeavengers.common.dto.entity.LocationCategoryAssn;
import org.codeavengers.main.data.jpa.JPAPersister;
import org.codeavengers.main.data.jpa.impl.CategoryPersister;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import test.codeavengers.config.TestRootConfig;
import test.codeavengers.util.ObjectMockingUtility;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
    TestRootConfig.class
})
public class TestCategoryPersister extends ObjectMockingUtility {
    @Autowired
    @Qualifier("CategoryPersister")
    private JPAPersister<Long, Category> persister;

    @Test
    public void testIdentify() {
        assertNotNull(persister);
        assertEquals(CategoryPersister.class.getSimpleName(), persister.identify());
    }

    @Rollback(true)
    @Test
    public void testAdd() {
        Category returnedLocation = persister.add(this.createCategoryDeep());
        assertNotNull(returnedLocation);
        assertNotNull(returnedLocation.getCatId());
    }

    @Rollback(true)
    @Test
    public void testUpdate() {
        Category category = persister.retrieve(211L);
        assertNotNull(category);

        category.setCatDesc("Rainfall");

        Category returnedCategory = persister.update(category);
        assertNotNull(returnedCategory);
        assertEquals("Rainfall", returnedCategory.getCatDesc());
    }

    @Rollback(true)
    @Test
    public void testDelete() {
        Category returnedCategory = persister.delete(11L);
        assertNotNull(returnedCategory);
    }

    @Test
    public void testRetrieve() {
        Category category = persister.retrieve(101L);
        assertNotNull(category);
        LocationCategoryAssn assn = category.getAssns().get(0);
        assertNotNull(assn);
        assertNotNull(assn.getLocation());
        assertEquals(101L, category.getCatId().longValue());
    }

    @Test
    public void testRetrieveAll() {
        List<Category> categories = persister.retrieveAll();
        for (Category category : categories) {
            System.out.println("Category : " + category);
        }
        assertNotNull(categories);
        assertFalse(categories.isEmpty());
    }

}<commit_msg>Removing SYSOUT<commit_after>/* Copyright 2015 <NAME> */

package test.codeavengers.main.data.jpa.impl;

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

import java.util.List;

import org.codeavengers.common.dto.entity.Category;
import org.codeavengers.common.dto.entity.LocationCategoryAssn;
import org.codeavengers.main.data.jpa.JPAPersister;
import org.codeavengers.main.data.jpa.impl.CategoryPersister;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import test.codeavengers.config.TestRootConfig;
import test.codeavengers.util.ObjectMockingUtility;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
    TestRootConfig.class
})
public class TestCategoryPersister extends ObjectMockingUtility {
    @Autowired
    @Qualifier("CategoryPersister")
    private JPAPersister<Long, Category> persister;

    @Test
    public void testIdentify() {
        assertNotNull(persister);
        assertEquals(CategoryPersister.class.getSimpleName(), persister.identify());
    }

    @Rollback(true)
    @Test
    public void testAdd() {
        Category returnedLocation = persister.add(this.createCategoryDeep());
        assertNotNull(returnedLocation);
        assertNotNull(returnedLocation.getCatId());
    }

    @Rollback(true)
    @Test
    public void testUpdate() {
        Category category = persister.retrieve(211L);
        assertNotNull(category);

        category.setCatDesc("Rainfall");

        Category returnedCategory = persister.update(category);
        assertNotNull(returnedCategory);
        assertEquals("Rainfall", returnedCategory.getCatDesc());
    }

    @Rollback(true)
    @Test
    public void testDelete() {
        Category returnedCategory = persister.delete(11L);
        assertNotNull(returnedCategory);
    }

    @Test
    public void testRetrieve() {
        Category category = persister.retrieve(101L);
        assertNotNull(category);
        LocationCategoryAssn assn = category.getAssns().get(0);
        assertNotNull(assn);
        assertNotNull(assn.getLocation());
        assertEquals(101L, category.getCatId().longValue());
    }

    @Test
    public void testRetrieveAll() {
        List<Category> categories = persister.retrieveAll();
        assertNotNull(categories);
        assertFalse(categories.isEmpty());
    }

}
{'fraction_non_alphanumeric': 0.10377188233170907, 'fraction_numerical': 0.006857967875834687, 'mean_word_length': 3.9972948602344456, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '6002707', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1529, 'n_words': 254}