<commit_before>package org.factcast.server.rest.resources;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;

import java.util.List;

import org.factcast.core.Fact;
import org.factcast.core.store.FactStore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

import com.fasterxml.jackson.databind.ObjectMapper;

@RunWith(MockitoJUnitRunner.class)
public class EventsTransactionsResourceTest {
    @Mock
    private FactStore factStore;

    @Spy
    private ObjectMapper objectMapper = new ObjectMapper();

    @InjectMocks
    private EventsTransactionsResource uut;

    @Test
    public void testNewTransaction() throws Exception {
        FactTransactionJson factTransactionJson = objectMapper.readValue(this.getClass()
                .getResourceAsStream("TransactionJson.json"), FactTransactionJson.class);
        uut.newTransaction(factTransactionJson);
        ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
        verify(factStore).publish(captor.capture());

        List<Fact> facts = captor.getValue();
        Fact fact = facts.get(0);
        FactJson sentFact = factTransactionJson.facts.get(0);
        assertEquals(sentFact.header.ns(), fact.ns());
        assertEquals(sentFact.header.aggIds(), fact.aggIds());
        assertEquals(sentFact.header.type(), fact.type());
        assertEquals(sentFact.header.id(), fact.id());
        assertEquals(objectMapper.writeValueAsString(sentFact.header), fact.jsonHeader());
        assertEquals(sentFact.payload.toString(), fact.jsonPayload());
    }

}<commit_msg>fixed compile error in test<commit_after>package org.factcast.server.rest.resources;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

import java.util.List;

import org.factcast.core.Fact;
import org.factcast.core.store.FactStore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

import com.fasterxml.jackson.databind.ObjectMapper;

@RunWith(MockitoJUnitRunner.class)
public class EventsTransactionsResourceTest {
    @Mock
    private FactStore factStore;

    @Spy
    private ObjectMapper objectMapper = new ObjectMapper();

    @InjectMocks
    private EventsTransactionsResource uut;

    @Test
    public void testNewTransaction() throws Exception {
        FactTransactionJson factTransactionJson = objectMapper.readValue(this.getClass()
                .getResourceAsStream("TransactionJson.json"), FactTransactionJson.class);
        uut.newTransaction(factTransactionJson);
        ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
        verify(factStore).publish(captor.capture());

        List<Fact> facts = captor.getValue();
        Fact fact = facts.get(0);
        FactJson sentFact = factTransactionJson.facts().get(0);
        assertEquals(sentFact.header().ns(), fact.ns());
        assertEquals(sentFact.header().aggIds(), fact.aggIds());
        assertEquals(sentFact.header().type(), fact.type());
        assertEquals(sentFact.header().id(), fact.id());
        assertEquals(objectMapper.writeValueAsString(sentFact.header()), fact.jsonHeader());
        assertEquals(sentFact.payload().toString(), fact.jsonPayload());
    }

}
{'fraction_non_alphanumeric': 0.11647727272727272, 'fraction_numerical': 0.0011363636363636363, 'mean_word_length': 4.263079222720478, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '988954', 'n_tokens_mistral': 1007, 'n_tokens_neox': 977, 'n_words': 174}