package com.fsck.k9.controller;


import android.support.annotation.NonNull;

import com.fsck.k9.controller.MessagingController.UidReverseComparator;
import com.fsck.k9.mail.Message;
import org.junit.Before;
import org.junit.Test;

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


@SuppressWarnings("ConstantConditions")
public class UidReverseComparatorTest {
    private UidReverseComparator comparator;


    @Before
    public void onBefore() {
        comparator = new UidReverseComparator();
    }

    @Test
    public void compare_withTwoNullArguments_shouldReturnZero() throws Exception {
        Message messageLeft = null;
        Message messageRight = null;

        int result = comparator.compare(messageLeft, messageRight);

        assertEquals("result must be 0 when both arguments are null", 0, result);
    }

    @Test
    public void compare_withLeftNullArgument_shouldReturnPositive() throws Exception {
        Message messageLeft = null;
        Message messageRight = mockMessage(1);

        int result = comparator.compare(messageLeft, messageRight);

        assertTrue("result must be > 0 when left argument is null", result > 0);
    }

    @Test
    public void compare_withRightNullArgument_shouldReturnNegative() throws Exception {
        Message messageLeft = mockMessage(1);
        Message messageRight = null;

        int result = comparator.compare(messageLeft, messageRight);

        assertTrue("result must be < 0 when right argument is null", result < 0);
    }

    @Test
    public void compare_twoMessages_shouldReturnOrderByUid() throws Exception {
        Message messageLeft = mockMessage(5);
        Message messageRight = mockMessage(15);

        int result = comparator.compare(messageLeft, messageRight);

        assertTrue("result must be > 0 when right message has larger UID than left message", result > 0);
    }

    @NonNull
    private static Message mockMessage(int uid1) {
        Message msg1 = mock(Message.class);
        when(msg1.getUid()).thenReturn(Integer.toString(uid1));
        return msg1;
    }
}

@@ -1104,35 +1104,44 @@
 sageRight = 
-mock
+create
 Message
+WithUid
 (1);%0A%0A      
@@ -1419,27 +1419,36 @@
 eLeft = 
-mock
+create
 Message
+WithUid
 (1);%0A   
@@ -1760,27 +1760,36 @@
 eLeft = 
-mock
+create
 Message
+WithUid
 (5);%0A   
@@ -1816,27 +1816,36 @@
 Right = 
-mock
+create
 Message
+WithUid
 (15);%0A%0A 
@@ -2054,23 +2054,16 @@
 ate 
-static 
 Message 
 mock
@@ -2062,27 +2062,36 @@
 age 
-mock
+create
 Message
+WithUid
 (int uid
 1) %7B
@@ -2086,17 +2086,16 @@
 (int uid
-1
 ) %7B%0A    
@@ -2107,19 +2107,22 @@
 essage m
-sg1
+essage
  = mock(
@@ -2151,19 +2151,22 @@
   when(m
-sg1
+essage
 .getUid(
@@ -2203,13 +2203,13 @@
 (uid
-1
 ));%0A
+%0A
     
@@ -2224,11 +2224,14 @@
 rn m
-sg1
+essage
 ;%0A  

Rename method