<commit_before>package pl.pw.edu.mini.dos.master;

import org.junit.Test;
import pl.pw.edu.mini.dos.communication.ErrorEnum;
import pl.pw.edu.mini.dos.communication.masternode.*;
import pl.pw.edu.mini.dos.communication.nodemaster.RegisterRequest;
import pl.pw.edu.mini.dos.master.node.RegisteredNode;

import java.rmi.RemoteException;
import java.util.List;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static org.mockito.Mockito.*;

/**
 * Created with IntelliJ IDEA.
 * User: asd
 * Date: 12/15/15
 * Time: 8:24 AM
 * To change this template use File | Settings | File Templates.
 */
public class MasterRegisterWithMockitoTest {
    private Master master;
    private MasterNodeInterface node;

    @org.junit.Before
    public void setUp() throws Exception {
        master = new Master();
        node = mock(MasterNodeInterface.class);
    }

    @Test
    public void testRegisterOneNode() throws InterruptedException, RemoteException {
        when(node.checkStatus(any(CheckStatusRequest.class)))
                .thenReturn(new CheckStatusResponse(0, 0, 0));
        when(node.createTables(any(ExecuteCreateTablesRequest.class)))
                .thenReturn(new ExecuteCreateTablesResponse(ErrorEnum.NO_ERROR));

        RegisterRequest registerRequest = new RegisterRequest(node);
        master.register(registerRequest);

        List<RegisteredNode> registeredNodes = master.nodeManager.getNodes();
        assertNotNull(registeredNodes);
        assertEquals(1, registeredNodes.size());
        assertEquals(node, registeredNodes.get(0).getInterface());
    }
<commit_msg>Added: Mockito test example with annotations.<commit_after>package pl.pw.edu.mini.dos.master;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import pl.pw.edu.mini.dos.communication.ErrorEnum;
import pl.pw.edu.mini.dos.communication.masternode.*;
import pl.pw.edu.mini.dos.communication.nodemaster.RegisterRequest;
import pl.pw.edu.mini.dos.master.node.RegisteredNode;

import java.rmi.RemoteException;
import java.util.List;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.when;

/**
 * Created with IntelliJ IDEA.
 * User: asd
 * Date: 12/15/15
 * Time: 8:24 AM
 * To change this template use File | Settings | File Templates.
 */
@RunWith(MockitoJUnitRunner.class)
public class MasterRegisterWithMockitoTest {
    private Master master;
    @Mock
    private MasterNodeInterface node;

    @org.junit.Before
    public void setUp() throws Exception {
        master = new Master();
    }

    @Test
    public void testRegisterOneNode() throws InterruptedException, RemoteException {
        when(node.checkStatus(any(CheckStatusRequest.class)))
                .thenReturn(new CheckStatusResponse(0, 0, 0));
        when(node.createTables(any(ExecuteCreateTablesRequest.class)))
                .thenReturn(new ExecuteCreateTablesResponse(ErrorEnum.NO_ERROR));

        RegisterRequest registerRequest = new RegisterRequest(node);
        master.register(registerRequest);

        List<RegisteredNode> registeredNodes = master.nodeManager.getNodes();
        assertNotNull(registeredNodes);
        assertEquals(1, registeredNodes.size());
        assertEquals(node, registeredNodes.get(0).getInterface());
    }

{'fraction_non_alphanumeric': 0.10517241379310345, 'fraction_numerical': 0.008045977011494253, 'mean_word_length': 3.987106017191977, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5712073', 'n_tokens_mistral': 1027, 'n_tokens_neox': 967, 'n_words': 200}