package io.smsc.listeners;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
public class EncryptionListenerUnitTest {

    private Object testObject;

    @Before
    public void setUp() {
        testObject = new Object();
    }

    @Mock
    private EncryptionListener listener;

    @Test(expected = IllegalAccessException.class)
    public void testEncryptCall() throws Exception {
        doThrow(IllegalAccessException.class).when(listener).encrypt(testObject);
        listener.encrypt(testObject);
    }

    @Test(expected = IllegalAccessException.class)
    public void testDecryptCall() throws Exception {
        doThrow(IllegalAccessException.class).when(listener).decrypt(testObject);
        listener.decrypt(testObject);
    }
}

@@ -21,16 +21,51 @@
 eners;%0A%0A
+import io.smsc.util.EncrypterUtil;%0A
 import o
@@ -208,16 +208,110 @@
 tRunner;
+%0Aimport org.springframework.test.util.ReflectionTestUtils;%0A%0Aimport java.awt.event.ActionEvent;
 %0A%0Aimport
@@ -460,41 +460,220 @@
     
-@Before%0A    public void setUp() %7B
+private EncryptionListener listener;%0A%0A    private ActionEvent mockEvent;%0A%0A    @Mock%0A    private EncryptionListener mockListener;%0A%0A    @Before%0A    public void setUp() %7B%0A        listener = new EncryptionListener();
 %0A   
@@ -712,61 +712,138 @@
     
-%7D%0A%0A
     
-@Mock%0A    private EncryptionListener listener;
+mockEvent = mock(ActionEvent.class);%0A%0A        ReflectionTestUtils.setField(EncrypterUtil.class, %22secretKey%22, %22smsc.io%22);%0A    %7D
 %0A%0A  
@@ -914,32 +914,45 @@
  testEncryptCall
+WithException
 () throws Except
@@ -1000,33 +1000,37 @@
 ion.class).when(
-l
+mockL
 istener).encrypt
@@ -1039,32 +1039,33 @@
 estObject);%0A
+%0A
         
 listener.enc
@@ -1044,33 +1044,37 @@
 ject);%0A%0A        
-l
+mockL
 istener.encrypt(
@@ -1175,16 +1175,29 @@
 ryptCall
+WithException
 () throw
@@ -1261,17 +1261,21 @@
 s).when(
-l
+mockL
 istener)
@@ -1296,24 +1296,25 @@
 bject);%0A
+%0A
         
 listener
@@ -1309,34 +1309,610 @@
     
-listener.decrypt(testObjec
+mockListener.decrypt(testObject);%0A    %7D%0A%0A    @Test%0A    public void testEncryptCallWithoutException() throws Exception %7B%0A        mockListener.encrypt(testObject);%0A%0A        verify(mockListener).encrypt(testObject);%0A    %7D%0A%0A    @Test%0A    public void testDecryptCallWithoutException() throws Exception %7B%0A        mockListener.decrypt(testObject);%0A%0A        verify(mockListener).decrypt(testObject);%0A    %7D%0A%0A    @Test%0A    public void testEncryptCall() throws Exception %7B%0A        listener.encrypt(mockEvent);%0A    %7D%0A%0A    @Test%0A    public void testDecryptCall() throws Exception %7B%0A        listener.decrypt(mockEven
 t);%0A

Add more unit tests for EncryptionListener