OK-499 Enhance Unittests
diff --git a/src/main/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFile.java b/src/main/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFile.java
index 54d23ee..ab3dc7d 100644
--- a/src/main/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFile.java
+++ b/src/main/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFile.java
@@ -29,17 +29,18 @@
 		LOGGER.info("getNotificationsFile() is called");
 		List<NotificationFile> notificationFiles = new ArrayList<>();
 
+		File folder = new File(pathName);
+		File[] listOfFiles = folder.listFiles();
+
+		return processChoiceGetNotificationFilesWithChoice(choice, notificationFiles, listOfFiles);
+	}
+
+	private List<NotificationFile> processChoiceGetNotificationFilesWithChoice(String choice, List<NotificationFile> notificationFiles, File[] listOfFiles) throws BtbInternalServerError {
 		try {
-
-			File folder = new File(pathName);
-			File[] listOfFiles = folder.listFiles();
-
-			if ("getImportFiles".equals(choice))
-			{
+			if ("getImportFiles".equals(choice)) {
 				processFileListForGetImportFiles(notificationFiles, listOfFiles);
 			}
-			else if ("importFile".equals(choice))
-			{
+			else if ("importFile".equals(choice)) {
 				processFileListForImportFile(notificationFiles, listOfFiles);
 			}
 			else {
diff --git a/src/test/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFileTest.java b/src/test/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFileTest.java
index 5096c27..95faefa 100644
--- a/src/test/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFileTest.java
+++ b/src/test/java/org/eclipse/openk/elogbook/controller/BackendControllerNotificationFileTest.java
@@ -1,6 +1,7 @@
 package org.eclipse.openk.elogbook.controller;
 
 import org.eclipse.openk.elogbook.common.BackendConfig;
+import org.eclipse.openk.elogbook.exceptions.BtbInternalServerError;
 import org.eclipse.openk.elogbook.viewmodel.NotificationFile;
 import org.junit.Test;
 import org.powermock.reflect.Whitebox;
@@ -20,6 +21,11 @@
     BackendControllerNotificationFile backConF = new BackendControllerNotificationFile();
 
     @Test
+    public void testGetNotificationFiles_Exception() throws BtbInternalServerError {
+        backConF.getNotificationsFiles("getImportFiles");
+    }
+
+    @Test
     public void testGetNotificationsFiles() throws Exception {
 
         File[] listOfFiles = new File[1];
@@ -30,15 +36,15 @@
 
         if (listOfFiles != null)
         {
-            List<NotificationFile> notFiles = Whitebox.invokeMethod(backConF, "getNotificationsFiles", "choice");
-            Whitebox.invokeMethod(backConF, "processFileListForGetImportFiles", notFiles, listOfFiles);
+            List<NotificationFile> notFiles = backConF.getNotificationsFiles("choice");
+            Whitebox.invokeMethod(backConF, "processChoiceGetNotificationFilesWithChoice", "getImportFiles", notFiles, listOfFiles);
 
             Path filePath = Paths.get(listOfFiles[0].toString());
             Files.write(filePath, lines);
             List<String> allTheLines = Files.readAllLines(filePath, Charset.defaultCharset());
             if (allTheLines.size() >= fileRowToRead)
             {
-                Whitebox.invokeMethod(backConF, "processFileListForImportFile", notFiles, listOfFiles);
+                Whitebox.invokeMethod(backConF, "processChoiceGetNotificationFilesWithChoice", "importFile", notFiles, listOfFiles);
 
             }
         }
@@ -61,6 +67,7 @@
         {
             lines.add(line2);
         }
+        lines.add("10:10:51,425 XX Text"); // unknown branch
 
         Whitebox.invokeMethod(backConF, "extractFileData", nf, lines);
 
diff --git a/src/test/java/org/eclipse/openk/elogbook/controller/ControllerImplementationsTest.java b/src/test/java/org/eclipse/openk/elogbook/controller/ControllerImplementationsTest.java
index 21f12b4..1cc5b86 100644
--- a/src/test/java/org/eclipse/openk/elogbook/controller/ControllerImplementationsTest.java
+++ b/src/test/java/org/eclipse/openk/elogbook/controller/ControllerImplementationsTest.java
@@ -29,9 +29,7 @@
 import java.util.List;
 
 import static junit.framework.TestCase.assertEquals;
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.*;
 
 
 public class ControllerImplementationsTest extends ResourceLoaderBase {
@@ -191,7 +189,7 @@
 
 
     @Test
-    public void testPostResponsibilities() throws BtbException {
+    public void testPostResponsibilities_NewerRespsAreNull() throws BtbException {
         List<TerritoryResponsibility> territoryResponsibilityList = new ArrayList<>();
 
         ControllerImplementations.PostResponsibilities controllerImpl = new ControllerImplementations.PostResponsibilities("", beMockResponsibility);
@@ -205,7 +203,21 @@
     }
 
     @Test
-    public void testPostResponsibilitiesConfirmation() throws BtbException {
+    public void testPostResponsibilities_NewerRespsNotNull() throws BtbException {
+        List<TerritoryResponsibility> territoryResponsibilityList = new ArrayList<>();
+
+        ControllerImplementations.PostResponsibilities controllerImpl = new ControllerImplementations.PostResponsibilities("", beMockResponsibility);
+        controllerImpl.setModUser("EgalUser");
+        expect(beMockResponsibility.planResponsibilities(anyObject(), anyString())).andReturn(new ArrayList<>());
+        PowerMock.replay(beMockResponsibility);
+
+        assertEquals(controllerImpl.invoke().getStatus(), Globals.HTTPSTATUS_OK);
+        assertEquals(controllerImpl.getModUser(), "EgalUser");
+
+    }
+
+    @Test
+    public void testPostResponsibilitiesConfirmation_NewerRespsAreNull() throws BtbException {
         List<TerritoryResponsibility> territoryResponsiblityList = new ArrayList<>();
 
         ControllerImplementations.PostResponsibilitiesConfirmation controllerImpl = new ControllerImplementations.PostResponsibilitiesConfirmation("", beMockResponsibility);
@@ -217,6 +229,19 @@
         assertEquals(controllerImpl.getModUser(), "EgalUser");
     }
 
+    @Test
+    public void testPostResponsibilitiesConfirmation_NewerRespsNotNull() throws BtbException {
+        List<TerritoryResponsibility> territoryResponsiblityList = new ArrayList<>();
+
+        ControllerImplementations.PostResponsibilitiesConfirmation controllerImpl = new ControllerImplementations.PostResponsibilitiesConfirmation("", beMockResponsibility);
+        controllerImpl.setModUser("EgalUser");
+        expect(beMockResponsibility.confirmResponsibilities(anyObject(), anyString())).andReturn(new ArrayList<>());
+        PowerMock.replay(beMockResponsibility);
+
+        assertEquals(controllerImpl.invoke().getStatus(), Globals.HTTPSTATUS_OK);
+        assertEquals(controllerImpl.getModUser(), "EgalUser");
+    }
+
 
     @Test
     public void testGetVersionInfo() throws BtbException {