package com.sleekbyte.tailor.output;

import com.sleekbyte.tailor.common.Messages;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import java.io.IOException;

import static junit.framework.Assert.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * Tests for {@link ViolationMessage}
 */
@RunWith(MockitoJUnitRunner.class)

public class ViolationMessageTest {

    ViolationMessage violationMessage;

    @Before
    public void setUp() throws IOException {
        ViolationMessage violationMessage = new ViolationMessage("/usr/bin/local", 10, 1, Messages.ERROR, "errMsg");
    }

    @Test
    public void testCompareTo() throws Exception { }

    @Test
    public void testEquals() throws Exception {
        // Equal ViolationMessage
        ViolationMessage unequalViolationMessage = new ViolationMessage("/usr/bin/local", 12, 5, Messages.ERROR, "errMsg");
        assertFalse(this.violationMessage.equals(unequalViolationMessage));

        // Unequal ViolationMessage
        ViolationMessage equalViolationMessage = new ViolationMessage("/usr/bin/local", 10, 1, Messages.ERROR, "errMsg");
        assertTrue(violationMessage.equals(equalViolationMessage));
    }

    @Test
    public void testToString() throws Exception {
        String expectedOutput = "/usr/bin/local:10:1: error: errMsg";
        assertEquals(expectedOutput, this.violationMessage.toString());
    }
}

@@ -76,16 +76,47 @@
 ssages;%0A
+import junit.framework.Assert;%0A
 import o
@@ -303,32 +303,26 @@
  static 
+org.
 junit.
-framework.
 Assert.a
@@ -352,32 +352,24 @@
 tic 
+org.
 junit.
-framework.TestCase
+Assert
 .ass
@@ -650,41 +650,292 @@
     
-ViolationMessage violationMessage
+this.violationMessage = new ViolationMessage(%22/usr/bin/local%22, 10, 1, Messages.ERROR, %22errMsg%22);%0A    %7D%0A%0A    @Test%0A    public void testCompareTo() throws Exception %7B%0A        // global message has lower line number than test message%0A        ViolationMessage messageWithGreaterLineNumber
  = n
@@ -965,36 +965,36 @@
 sr/bin/local%22, 1
-0, 1
+2, 5
 , Messages.ERROR
@@ -1014,71 +1014,1454 @@
     
-%7D%0A%0A    @Test%0A    public void testCompareTo() throws Exception %7B
+    int ret = this.violationMessage.compareTo(messageWithGreaterLineNumber);%0A        Assert.assertTrue(ret %3C 0);%0A%0A        // global message has greater line number than test message%0A        ViolationMessage messageWithLesserLineNumber = new ViolationMessage(%22/usr/bin/local%22, 8, 5, Messages.ERROR, %22errMsg%22);%0A        ret = this.violationMessage.compareTo(messageWithLesserLineNumber);%0A        Assert.assertTrue(ret %3E 0);%0A%0A        // global message has equal line number but greater column number than test message%0A        ViolationMessage messageWithGreaterColumnNumber = new ViolationMessage(%22/usr/bin/local%22, 10, 2, Messages.ERROR, %22errMsg%22);%0A        ret = this.violationMessage.compareTo(messageWithGreaterColumnNumber);%0A        Assert.assertTrue(ret %3C 0);%0A%0A        // global message has equal line number but lesser column number than test message%0A        ViolationMessage messageWithLesserColumnNumber = new ViolationMessage(%22/usr/bin/local%22, 10, 0, Messages.WARNING, %22warningMsg%22);%0A        ret = this.violationMessage.compareTo(messageWithLesserColumnNumber);%0A        Assert.assertTrue(ret %3E 0);%0A%0A        // global message has equal line number and column number wrt test message%0A        ViolationMessage messageWithEqualLineColumnNumber = new ViolationMessage(%22/usr/bin/local%22, 10, 1, Messages.WARNING, %22warningMsg%22);%0A        ret = this.violationMessage.compareTo(messageWithEqualLineColumnNumber);%0A        Assert.assertTrue(ret == 0);%0A   
  %7D%0A%0A
@@ -2930,16 +2930,21 @@
 ertTrue(
+this.
 violatio

Test ViolationMessage::compareTo()