<commit_before>package org.netmelody.cieye.server.response.responder.test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.Test;
import org.netmelody.cieye.core.domain.CiServerType;
import org.netmelody.cieye.core.domain.Feature;
import org.netmelody.cieye.core.domain.Landscape;
import org.netmelody.cieye.core.domain.TargetDetailGroup;
import org.netmelody.cieye.server.CiSpyAllocator;
import org.netmelody.cieye.server.CiSpyHandler;
import org.netmelody.cieye.server.response.Prison;
import org.netmelody.cieye.server.response.responder.LandscapeObservationResponder;
import org.simpleframework.http.Response;

public final class LandscapeObservationResponderTest {

    private final Mockery context = new Mockery();
    
    private final CiSpyAllocator spyAllocator = context.mock(CiSpyAllocator.class);
    
    private final Feature feature = new Feature("F", "E", new CiServerType("J"));
    
    private final LandscapeObservationResponder responder = new LandscapeObservationResponder(new Landscape("L", feature),
                                                                                              spyAllocator,
                                                                                              new Prison());
    
    @Test public void
    respondsWithCorrectJsonWhenNoTargetsArePresent() throws IOException {
        final Response response = context.mock(Response.class);
        final ByteArrayOutputStream output = new ByteArrayOutputStream();
        final PrintStream printStream = new PrintStream(output);
        final CiSpyHandler spy = context.mock(CiSpyHandler.class);
        final TargetDetailGroup targets = new TargetDetailGroup();
        
        context.checking(new Expectations() {{
            allowing(response).getPrintStream(); will(returnValue(printStream));
            ignoring(response);
            
            allowing(spyAllocator).spyFor(feature); will(returnValue(spy));
            allowing(spy).statusOf(feature); will(returnValue(targets));
            ignoring(spy);
        }});
        
        responder.writeTo(response);
        
        assertThat(output.toString(), is("{\"targets\":[]}\r\n"));
    }

}<commit_msg>fix test for platform independence<commit_after>package org.netmelody.cieye.server.response.responder.test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.Test;
import org.netmelody.cieye.core.domain.CiServerType;
import org.netmelody.cieye.core.domain.Feature;
import org.netmelody.cieye.core.domain.Landscape;
import org.netmelody.cieye.core.domain.TargetDetailGroup;
import org.netmelody.cieye.server.CiSpyAllocator;
import org.netmelody.cieye.server.CiSpyHandler;
import org.netmelody.cieye.server.response.Prison;
import org.netmelody.cieye.server.response.responder.LandscapeObservationResponder;
import org.simpleframework.http.Response;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.startsWith;

public final class LandscapeObservationResponderTest {

    private final Mockery context = new Mockery();
    
    private final CiSpyAllocator spyAllocator = context.mock(CiSpyAllocator.class);
    
    private final Feature feature = new Feature("F", "E", new CiServerType("J"));
    
    private final LandscapeObservationResponder responder = new LandscapeObservationResponder(new Landscape("L", feature),
                                                                                              spyAllocator,
                                                                                              new Prison());
    
    @Test public void
    respondsWithCorrectJsonWhenNoTargetsArePresent() throws IOException {
        final Response response = context.mock(Response.class);
        final ByteArrayOutputStream output = new ByteArrayOutputStream();
        final PrintStream printStream = new PrintStream(output);
        final CiSpyHandler spy = context.mock(CiSpyHandler.class);
        final TargetDetailGroup targets = new TargetDetailGroup();
        
        context.checking(new Expectations() {{
            allowing(response).getPrintStream(); will(returnValue(printStream));
            ignoring(response);
            
            allowing(spyAllocator).spyFor(feature); will(returnValue(spy));
            allowing(spy).statusOf(feature); will(returnValue(targets));
            ignoring(spy);
        }});
        
        responder.writeTo(response);
        
        assertThat(output.toString(), startsWith("{\"targets\":[]}"));
    }

}
{'fraction_non_alphanumeric': 0.09441352298495155, 'fraction_numerical': 0.0, 'mean_word_length': 2.8723064644852356, 'pattern_counts': {'":': 2, '<': 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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6652631', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1265, 'n_words': 234}