<commit_before>package dk.statsbiblioteket.medieplatform.autonomous;

import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.FileInputStream;
import java.util.Date;
import java.util.Properties;

public class DomsEventClientIntegrationTest {

    @Test(groups = "integrationTest")
    public void testAddEventToBatch1() throws Exception {
        String pathToProperties = System.getProperty("integration.test.newspaper.properties");
        Properties props = new Properties();
        props.load(new FileInputStream(pathToProperties));

        DomsEventClientFactory factory = new DomsEventClientFactory();
        factory.setFedoraLocation(props.getProperty(ConfigConstants.DOMS_URL));
        factory.setUsername(props.getProperty(ConfigConstants.DOMS_USERNAME));
        factory.setPassword(props.getProperty(ConfigConstants.DOMS_PASSWORD));
        factory.setPidGeneratorLocation(props.getProperty(ConfigConstants.DOMS_PIDGENERATOR_URL));


        DomsEventClient doms = factory.createDomsEventClient();


        String batchId = "400022028242";
        Integer roundTripNumber = 1;
        Date timestamp = new Date(0);
        String eventID = "Data_Received";
        String details = "Details here";
        doms.addEventToBatch(
                batchId, roundTripNumber, "agent", timestamp, details, eventID, true);

        Batch batch = doms.getBatch(batchId, roundTripNumber);
        Assert.assertEquals(batch.getBatchID(), batchId);
        Assert.assertEquals(batch.getRoundTripNumber(), roundTripNumber);

        boolean found = false;
        for (Event event : batch.getEventList()) {
            if (event.getEventID()
                     .equals(eventID)) {
                found = true;
                Assert.assertEquals(event.getDate(), timestamp);
                Assert.assertEquals(event.getDetails(), details);
                Assert.assertEquals(event.isSuccess(), true);
            }
        }
        Assert.assertTrue(found);


        Integer newRoundTripNumber = roundTripNumber + 5;
        doms.addEventToBatch(
                batchId, newRoundTripNumber, "agent", timestamp, details, eventID, true);

        batch = doms.getBatch(batchId, newRoundTripNumber);
        Assert.assertEquals(batch.getBatchID(), batchId);
        Assert.assertEquals(batch.getRoundTripNumber(), newRoundTripNumber);

        found = false;
        for (Event event : batch.getEventList()) {
            if (event.getEventID()
                     .equals(eventID)) {
                found = true;
                Assert.assertEquals(event.getDate(), timestamp);
                Assert.assertEquals(event.getDetails(), details);
                Assert.assertEquals(event.isSuccess(), true);
            }
        }
        Assert.assertTrue(found);


    }

}
<commit_msg>Fixed integration test so it uses a nonexiting batch.<commit_after>package dk.statsbiblioteket.medieplatform.autonomous;

import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.FileInputStream;
import java.util.Date;
import java.util.Properties;

public class DomsEventClientIntegrationTest {

    @Test(groups = "integrationTest")
    public void testAddEventToBatch1() throws Exception {
        String pathToProperties = System.getProperty("integration.test.newspaper.properties");
        Properties props = new Properties();
        props.load(new FileInputStream(pathToProperties));

        DomsEventClientFactory factory = new DomsEventClientFactory();
        factory.setFedoraLocation(props.getProperty(ConfigConstants.DOMS_URL));
        factory.setUsername(props.getProperty(ConfigConstants.DOMS_USERNAME));
        factory.setPassword(props.getProperty(ConfigConstants.DOMS_PASSWORD));
        factory.setPidGeneratorLocation(props.getProperty(ConfigConstants.DOMS_PIDGENERATOR_URL));


        DomsEventClient doms = factory.createDomsEventClient();


        String batchId = "400022025243";
        Integer roundTripNumber = 1;
        Date timestamp = new Date(0);
        String eventID = "Data_Received";
        String details = "Details here";
        doms.addEventToBatch(
                batchId, roundTripNumber, "agent", timestamp, details, eventID, true);

        Batch batch = doms.getBatch(batchId, roundTripNumber);
        Assert.assertEquals(batch.getBatchID(), batchId);
        Assert.assertEquals(batch.getRoundTripNumber(), roundTripNumber);

        boolean found = false;
        for (Event event : batch.getEventList()) {
            if (event.getEventID()
                     .equals(eventID)) {
                found = true;
                Assert.assertEquals(event.getDate(), timestamp);
                Assert.assertEquals(event.getDetails(), details);
                Assert.assertEquals(event.isSuccess(), true);
            }
        }
        Assert.assertTrue(found);


        Integer newRoundTripNumber = roundTripNumber + 5;
        doms.addEventToBatch(
                batchId, newRoundTripNumber, "agent", timestamp, details, eventID, true);

        batch = doms.getBatch(batchId, newRoundTripNumber);
        Assert.assertEquals(batch.getBatchID(), batchId);
        Assert.assertEquals(batch.getRoundTripNumber(), newRoundTripNumber);

        found = false;
        for (Event event : batch.getEventList()) {
            if (event.getEventID()
                     .equals(eventID)) {
                found = true;
                Assert.assertEquals(event.getDate(), timestamp);
                Assert.assertEquals(event.getDetails(), details);
                Assert.assertEquals(event.isSuccess(), true);
            }
        }
        Assert.assertTrue(found);


    }

}

{'fraction_non_alphanumeric': 0.10052816901408451, 'fraction_numerical': 0.005633802816901409, 'mean_word_length': 2.7375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5049768', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1455, 'n_words': 270}