<commit_before>package au.gov.ga.geodesy.domain.model;

import static org.testng.Assert.assertEquals;

import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
import org.springframework.transaction.annotation.Transactional;
import org.testng.annotations.Test;

import au.gov.ga.geodesy.interfaces.geodesyml.GeodesyMLMarshaller;
import au.gov.ga.geodesy.port.adapter.geodesyml.CorsSiteLogFactory;
import au.gov.ga.geodesy.support.spring.GeodesySupportConfig;
import au.gov.ga.geodesy.support.spring.PersistenceJpaConfig;
import au.gov.xml.icsm.geodesyml.v_0_2_2.GeodesyMLType;

@ContextConfiguration(
        classes = {GeodesySupportConfig.class, PersistenceJpaConfig.class},
        loader = AnnotationConfigContextLoader.class)

@Transactional("geodesyTransactionManager")
public class CorsSiteLogRepositoryTest extends AbstractTransactionalTestNGSpringContextTests {

    private static final Logger log = LoggerFactory.getLogger(CorsSiteLogRepositoryTest.class);

    @Autowired
    private CorsSiteLogRepository siteLogs;

    @Autowired
    private GeodesyMLMarshaller marshaller;

    private static final String sampleSiteLogsDir = "src/test/resources/sitelog/geodesyml";

    @Test
    @Rollback(false)
    public void saveAllSiteLogs() throws Exception {
        for (File f : getSiteLogFiles()) {
            GeodesyMLType geodesyML = marshaller.unmarshal(new FileReader(f)).getValue();
            new CorsSiteLogFactory(geodesyML).create()
                .forEach(siteLog -> {
                    log.info("Saving " + siteLog.getFourCharacterId());
                    siteLogs.saveAndFlush(siteLog);
                });
        }
    }

    @Test(dependsOnMethods = "saveAllSiteLogs")
    public void checkNumberOfSavedLogs() throws Exception {
        assertEquals(siteLogs.count(), 1);
    }

    private File[] getSiteLogFiles() throws Exception {<commit_msg>Pass type argument to GeodesyML marshaller<commit_after>package au.gov.ga.geodesy.domain.model;

import static org.testng.Assert.assertEquals;

import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
import org.springframework.transaction.annotation.Transactional;
import org.testng.annotations.Test;

import au.gov.ga.geodesy.interfaces.geodesyml.GeodesyMLMarshaller;
import au.gov.ga.geodesy.port.adapter.geodesyml.CorsSiteLogFactory;
import au.gov.ga.geodesy.support.spring.GeodesySupportConfig;
import au.gov.ga.geodesy.support.spring.PersistenceJpaConfig;
import au.gov.xml.icsm.geodesyml.v_0_2_2.GeodesyMLType;

@ContextConfiguration(
        classes = {GeodesySupportConfig.class, PersistenceJpaConfig.class},
        loader = AnnotationConfigContextLoader.class)

@Transactional("geodesyTransactionManager")
public class CorsSiteLogRepositoryTest extends AbstractTransactionalTestNGSpringContextTests {

    private static final Logger log = LoggerFactory.getLogger(CorsSiteLogRepositoryTest.class);

    @Autowired
    private CorsSiteLogRepository siteLogs;

    @Autowired
    private GeodesyMLMarshaller marshaller;

    private static final String sampleSiteLogsDir = "src/test/resources/sitelog/geodesyml";

    @Test
    @Rollback(false)
    public void saveAllSiteLogs() throws Exception {
        for (File f : getSiteLogFiles()) {
            GeodesyMLType geodesyML = marshaller.unmarshal(new FileReader(f), GeodesyMLType.class).getValue();
            new CorsSiteLogFactory(geodesyML).create()
                .forEach(siteLog -> {
                    log.info("Saving " + siteLog.getFourCharacterId());
                    siteLogs.saveAndFlush(siteLog);
                });
        }
    }

    @Test(dependsOnMethods = "saveAllSiteLogs")
    public void checkNumberOfSavedLogs() throws Exception {
        assertEquals(siteLogs.count(), 1);
    }

    private File[] getSiteLogFiles() throws Exception {
{'fraction_non_alphanumeric': 0.09098712446351931, 'fraction_numerical': 0.002575107296137339, 'mean_word_length': 4.407192575406032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4557863', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1346, 'n_words': 218}