<commit_before>/**
 * This file is part of Mobile Robot Framework.
 * Mobile Robot Framework is free software under the terms of GNU AFFERO GENERAL PUBLIC LICENSE.
 */
package de.developgroup.mrf.server.handler;

import de.developgroup.mrf.server.ClientManager;
import junit.runner.Version;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.List;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;

public class ClientInformationHandlerTest {
    ClientInformationHandler handler;

    @Before
    public void setUp() {
        handler = new ClientInformationHandler();
        System.out.println("Set up handler");
//                mock(ClientManager.class)

    }

    @After
    public void tearDown() {
    }


    @Test
    public void testIsBlockedUnknownIp() throws IOException {
        boolean isBlocked = handler.isBlocked("ipAddressThatIsNotContainedInList");
        assertFalse(isBlocked);
    }

    @Test
    public void testClientInformationListEmpty() throws IOException {
        List<ClientInformation> clientInformationList = handler.getClientInformationList();
        assertEquals("clientInformationList should initially be empty", clientInformationList.size(), 0);
    }

    @Test
    public void testGetClientInformationAddUserWithUnregisteredIp() throws IOException {
        handler.addClientInformation(1337, "Firefox", "Windows");

        List<ClientInformation> clientInformationList = handler.getClientInformationList();

        assertEquals("clientInformationList should contain no intems after inserting information " +
                "with unregistered ip, but contains " + clientInformationList.size(), clientInformationList.size(), 0);
    }

    @Test
    public void testGetClientInformationAddUserWithKnownIp() throws IOException {
        handler.addConnection("192.168.0.42", 1337);
        handler.addClientInformation(1337, "Firefox", "Windows");

        List<ClientInformation> clientInformationList = handler.getClientInformationList();

        assertEquals("clientInformationList should contain 1 intem after inserting it, but contains " +
                clientInformationList.size(), clientInformationList.size(), 1);
        ClientInformation clientInformation = clientInformationList.get(0);
        assertEquals("IpAddres should be the one inserted before", clientInformation.getIpAddress(), "192.168.0.42");
        assertEquals("OperatingSystem should be the one inserted before", clientInformation.getOperatingSystem(), "Windows");
        List<String> browsers = clientInformation.getBrowsers();
        assertEquals("Browser should contain exactly one element", browsers.size(), 1);
        assertEquals("Browser should be the one inserted before", (String) browsers.get(0), "Firefox");
        List<Integer> clientIds = clientInformation.getClientIds();
        assertTrue("ClientId should contain exactly one element", clientIds.size() == 1);
        assertEquals("ClientId should be the one inserted before", (int) clientIds.get(0), 1337);
    }

    @Test
    public void testNoConnectedClientsOnStartup() throws IOException{
        List<ClientInformation> blockedConnections = handler.getBlockedConnections();
        assertEquals("blockedConnections should contain no items on startup, " +
                "but contains " + blockedConnections.size(), blockedConnections.size(), 0);

        List<ClientInformation> unblockedConnections = handler.getUnblockedConnections();
        assertEquals("unblockedConnections should contain no items on startup, " +
                "but contains " + unblockedConnections.size(), unblockedConnections.size(), 0);
<commit_msg>Putting arguments for assertEquals in correct order<commit_after>/**
 * This file is part of Mobile Robot Framework.
 * Mobile Robot Framework is free software under the terms of GNU AFFERO GENERAL PUBLIC LICENSE.
 */
package de.developgroup.mrf.server.handler;

import de.developgroup.mrf.server.ClientManager;
import junit.runner.Version;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.List;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;

public class ClientInformationHandlerTest {
    ClientInformationHandler handler;

    @Before
    public void setUp() {
        handler = new ClientInformationHandler();
        System.out.println("Set up handler");
//                mock(ClientManager.class)

    }

    @After
    public void tearDown() {
    }


    @Test
    public void testIsBlockedUnknownIp() throws IOException {
        boolean isBlocked = handler.isBlocked("ipAddressThatIsNotContainedInList");
        assertFalse(isBlocked);
    }

    @Test
    public void testClientInformationListEmpty() throws IOException {
        List<ClientInformation> clientInformationList = handler.getClientInformationList();
        assertEquals("clientInformationList should initially be empty", 0, clientInformationList.size());
    }

    @Test
    public void testGetClientInformationAddUserWithUnregisteredIp() throws IOException {
        handler.addClientInformation(1337, "Firefox", "Windows");

        List<ClientInformation> clientInformationList = handler.getClientInformationList();

        assertEquals("clientInformationList should contain no intems after inserting information " +
                "with unregistered ip, but contains " + clientInformationList.size(), 0, clientInformationList.size());
    }

    @Test
    public void testGetClientInformationAddUserWithKnownIp() throws IOException {
        handler.addConnection("192.168.0.42", 1337);
        handler.addClientInformation(1337, "Firefox", "Windows");

        List<ClientInformation> clientInformationList = handler.getClientInformationList();

        assertEquals("clientInformationList should contain 1 intem after inserting it, but contains " +
                clientInformationList.size(), 1, clientInformationList.size());
        ClientInformation clientInformation = clientInformationList.get(0);
        assertEquals("IpAddres should be the one inserted before", "192.168.0.42", clientInformation.getIpAddress());
        assertEquals("OperatingSystem should be the one inserted before", "Windows", clientInformation.getOperatingSystem());
        List<String> browsers = clientInformation.getBrowsers();
        assertEquals("Browser should contain exactly one element", 1, browsers.size());
        assertEquals("Browser should be the one inserted before", "Firefox", (String) browsers.get(0));
        List<Integer> clientIds = clientInformation.getClientIds();
        assertTrue("ClientId should contain exactly one element", clientIds.size() == 1);
        assertEquals("ClientId should be the one inserted before", 1337, (int) clientIds.get(0));
    }

    @Test
    public void testNoConnectedClientsOnStartup() throws IOException{
        List<ClientInformation> blockedConnections = handler.getBlockedConnections();
        assertEquals("blockedConnections should contain no items on startup, " +
                "but contains " + blockedConnections.size(), 0, blockedConnections.size());

        List<ClientInformation> unblockedConnections = handler.getUnblockedConnections();
        assertEquals("unblockedConnections should contain no items on startup, " +
                "but contains " + unblockedConnections.size(), 0, unblockedConnections.size());

{'fraction_non_alphanumeric': 0.0921120913336793, 'fraction_numerical': 0.01167618059159315, 'mean_word_length': 4.048461034708579, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '3961342', 'n_tokens_mistral': 1958, 'n_tokens_neox': 1841, 'n_words': 510}