Fixed errors in tests.

Change-Id: Ib6a7cd263e598a6dc83075eabd1220453a51f4f1
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
index 6217c89..86d6d60 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
@@ -13,6 +13,7 @@
 import de.ids_mannheim.korap.user.ShibUser;
 import de.ids_mannheim.korap.user.DemoUser;
 import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.user.User.UserFactory;
 import de.ids_mannheim.korap.utils.BooleanUtils;
 import de.ids_mannheim.korap.utils.TimeUtils;
 import org.slf4j.Logger;
@@ -55,52 +56,53 @@
      * getAccount(): KorAPUser:  Account muss vorhanden sein.
      *               DemoUser, DefaultUser: Account nicht vorhanden.
      */
-    @Override
-    public User getAccount (String username) throws KustvaktException {
-    	
-    	Map<String, String> namedParameters = Collections.singletonMap("username", username);
-        final String sql = "select a.* from korap_users as a where a.username=:username;";
-        User user = null;
-        
-        try {
-            user = this.jdbcTemplate.queryForObject(sql, namedParameters,
-                    new RowMapperFactory.UserMapper());
-            return user;
-        	}
-        catch (EmptyResultDataAccessException ae) {
-            jlog.warn("No user found for name '{}'", username);
-            // if no username, so return a DemoUser , FB.
-            // return User.UserFactory.getDemoUser();
-        	}
-        catch (DataAccessException e) {
-            jlog.warn("Could not retrieve user for name: " + username, e);
-            
-            /* DemoUser and DefaultUser have no account,
-             * so it's ok they are not found.
-            throw new DatabaseException(username, "korap_users",
-                    StatusCodes.DB_GET_FAILED,
-                    "Could not retrieve the user with username: " + username,
-                    username);
-             */
-            }
-
-        // DemoUser or DefaultUser?
-        
-        {	// User cannot be found in SQL DB since LDAP Authentication,
-        	// so create a User Object here.
-        	// TODO: what more data should be stored into it?
-        	// 28.04.17/FB
-        	user = new KorAPUser(); // oder eigentlich new DemoUser oder new DefaultUser.
-        	user.setUsername(username);
-        	return user;
-        }
-        
-        
-    }
+//    @Override
+//    public User getAccount (String username) throws KustvaktException {
+//    	
+//    	Map<String, String> namedParameters = Collections.singletonMap("username", username);
+//        final String sql = "select a.* from korap_users as a where a.username=:username;";
+//        User user = null;
+//        
+//        try {
+//            user = this.jdbcTemplate.queryForObject(sql, namedParameters,
+//                    new RowMapperFactory.UserMapper());
+//            return user;
+//        	}
+//        catch (EmptyResultDataAccessException ae) {
+//            jlog.warn("No user found for name '{}'", username);
+//            // if no username, so return a DemoUser , FB.
+//            // return User.UserFactory.getDemoUser();
+//            	return UserFactory.getDemoUser();
+//        	}
+//        catch (DataAccessException e) {
+//            jlog.warn("Could not retrieve user for name: " + username, e);
+//            
+//            /* DemoUser and DefaultUser have no account,
+//             * so it's ok they are not found.
+//            throw new DatabaseException(username, "korap_users",
+//                    StatusCodes.DB_GET_FAILED,
+//                    "Could not retrieve the user with username: " + username,
+//                    username);
+//             */
+//            }
+//
+//        // DemoUser or DefaultUser?
+//        
+//        {	// User cannot be found in SQL DB since LDAP Authentication,
+//        	// so create a User Object here.
+//        	// TODO: what more data should be stored into it?
+//        	// 28.04.17/FB
+//        	user = new KorAPUser(); // oder eigentlich new DemoUser oder new DefaultUser.
+//        	user.setUsername(username);
+//        	return user;
+//        }
+//        
+//        
+//    }
 
     // usersettings are fetched plus basic account info, no details, since i rarely use them anyway! (by Hanl)
     /* Version before LDAP Authentication - 09.05.17/FB
-    @Deprecated
+    @Deprecated */
     @Override
     public User getAccount (String username) throws KustvaktException {
     	
@@ -127,7 +129,7 @@
         }
         return user;
     }
-	*/
+	
 
     @Override
     public int updateAccount (User user) throws KustvaktException {
diff --git a/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java b/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
index 0d3f495..47a215d 100644
--- a/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/ResourceFinder.java
@@ -153,7 +153,7 @@
 
         if (sets.isEmpty()){
             throw new KustvaktException(StatusCodes.NO_VALUE_FOUND, 
-                    "Cannot found public "+clazz.toString()+" with ids: "+id_set.toString());
+                    "Cannot found public "+clazz.getSimpleName()+" with ids: "+id_set.toString());
         }
         return sets;
     }
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java b/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
index 14614c6..3db2f05 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
@@ -1,5 +1,9 @@
 package de.ids_mannheim.korap.web.service;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import de.ids_mannheim.korap.config.Attributes;
 import de.ids_mannheim.korap.config.ContextHolder;
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
@@ -15,6 +19,23 @@
     public void load (ContextHolder beans) throws KustvaktException {
         AuthenticationManagerIface manager = beans.getAuthenticationManager();
         manager.createUserAccount(KustvaktConfiguration.KUSTVAKT_USER, false);
+        
+        // EM: Fix me
+        // EM: Hack for LDAP User
+        // 
+        Map<String, Object> ldapUser = new HashMap<>();
+        ldapUser.put(Attributes.ID, 101);
+        ldapUser.put(Attributes.USERNAME, "LDAPDefaultUser");
+        ldapUser.put(Attributes.PASSWORD, "unnecessary123");
+        ldapUser.put(Attributes.EMAIL, "korap@ids-mannheim.de");
+        ldapUser.put(Attributes.COUNTRY, "unnecessary");
+        ldapUser.put(Attributes.ADDRESS, "unnecessary");
+        ldapUser.put(Attributes.FIRSTNAME, "unnecessary");
+        ldapUser.put(Attributes.LASTNAME, "unnecessary");
+        ldapUser.put(Attributes.INSTITUTION, "IDS");
+        ldapUser.put(Attributes.IS_ADMIN, "false");
+        
+        manager.createUserAccount(ldapUser, false);
     }
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoLegacyServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoLegacyServiceTest.java
index ce459d9..d5b85fc 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoLegacyServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoLegacyServiceTest.java
@@ -65,7 +65,7 @@
         JsonNode node = JsonUtils.readTree(entity);
         assertNotNull(node);
         assertEquals(101, node.at("/errors/0/0").asInt());
-        assertEquals("[Cannot found public resources with ids: [WPD15]]",
+        assertEquals("[Cannot found public Corpus with ids: [WPD15]]",
                 node.at("/errors/0/2").asText());
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
index ce0e6ec..fe8c672 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
@@ -72,7 +72,7 @@
         String ent = response.getEntity(String.class);
         JsonNode node = JsonUtils.readTree(ent);
         assertEquals(101, node.at("/errors/0/0").asInt());
-        assertEquals("[Cannot found public resources with ids: [ZUW19]]",
+        assertEquals("[Cannot found public Corpus with ids: [ZUW19]]",
                 node.at("/errors/0/2").asText());
     }
     
@@ -90,7 +90,7 @@
         String ent = response.getEntity(String.class);
         JsonNode node = JsonUtils.readTree(ent);
         assertEquals(101, node.at("/errors/0/0").asInt());
-        assertEquals("[Cannot found public resources with ids: [BRZ10]]",
+        assertEquals("[Cannot found public Corpus with ids: [BRZ10]]",
                 node.at("/errors/0/2").asText());
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
index a7689ca..d31d91c 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
@@ -94,7 +94,7 @@
         assertNotNull(node);
         assertNotEquals(0, node.size());
         assertEquals(101, node.at("/errors/0/0").asInt());
-        assertEquals("[Cannot found public resources with ids: [WPD15-VC]]",
+        assertEquals("[Cannot found public VirtualCollection with ids: [WPD15-VC]]",
                 node.at("/errors/0/2").asText());
     }
     
@@ -181,7 +181,7 @@
         assertNotNull(node);
         assertNotEquals(0, node.size());
         assertEquals(101, node.at("/errors/0/0").asInt());
-        assertEquals("[Cannot found public resources with ids: [ZUW19]]",
+        assertEquals("[Cannot found public Corpus with ids: [ZUW19]]",
                 node.at("/errors/0/2").asText());
     }
 
@@ -199,7 +199,7 @@
         assertNotNull(node);
         assertNotEquals(0, node.size());
         assertEquals(101, node.at("/errors/0/0").asInt());
-        assertEquals("[Cannot found public resources with ids: [BRZ10]]",
+        assertEquals("[Cannot found public Corpus with ids: [BRZ10]]",
                 node.at("/errors/0/2").asText());
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
index 94cc478..2f92000 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
@@ -220,7 +220,7 @@
         String ent = response.getEntity(String.class);
         JsonNode error = JsonUtils.readTree(ent).get("errors").get(0);
         assertEquals(101, error.get(0).asInt());
-        assertEquals("[Cannot found public resources with ids: [WPD15]]",
+        assertEquals("[Cannot found public Corpus with ids: [WPD15]]",
                 error.get(2).asText());
     }