user data db
diff --git a/src/test/java/UserdataTest.java b/src/test/java/UserdataTest.java
index ea47a99..b635ddc 100644
--- a/src/test/java/UserdataTest.java
+++ b/src/test/java/UserdataTest.java
@@ -1,4 +1,5 @@
import de.ids_mannheim.korap.config.BeanConfiguration;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.user.*;
import org.junit.AfterClass;
import org.junit.Before;
@@ -64,26 +65,43 @@
data.addField(Attributes.COUNTRY, "Germany");
String[] req = data.requiredFields();
- String[] r = data.validationReturn();
+ String[] r = data.missing();
assert r.length > 0;
assert r.length == req.length;
assert !data.isValid();
}
@Test
- public void testUserdatafactory() {
+ public void testSettingsValidation() {
+ Userdata data = new UserSettings2(1);
+ data.addField(Attributes.FILE_FORMAT_FOR_EXPORT, "export");
+
+ String[] req = data.requiredFields();
+ String[] r = data.missing();
+ assert r.length == 0;
+ assert r.length == req.length;
+ assert data.isValid();
+ }
+
+ @Test
+ public void testUserdatafactory() throws KustvaktException {
UserDataDbIface dao = UserdataFactory
.getDaoInstance(Userdetails2.class);
assert UserDetailsDao.class.equals(dao.getClass());
}
- @Test(expected = RuntimeException.class)
- public void testUserdatafactoryError() {
+ @Test(expected = KustvaktException.class)
+ public void testUserdatafactoryError() throws KustvaktException {
UserdataFactory.getDaoInstance(new Userdata(1) {
@Override
public String[] requiredFields() {
return new String[0];
}
+
+ @Override
+ public String[] defaultFields() {
+ return new String[0];
+ }
}.getClass());
}
diff --git a/src/test/java/de/ids_mannheim/korap/config/TestHelper.java b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
index 739b16d..c96906d 100644
--- a/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
+++ b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
@@ -33,6 +33,10 @@
Map m = new HashMap<>();
m.put(Attributes.USERNAME, credentials[0]);
m.put(Attributes.PASSWORD, credentials[1]);
+ m.put(Attributes.FIRSTNAME, "test");
+ m.put(Attributes.LASTNAME, "user");
+ m.put(Attributes.EMAIL, "test@ids-mannheim.de");
+ m.put(Attributes.ADDRESS, "Mannheim");
Assert.assertNotNull("userdatabase handler must not be null", dao);
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java
index 9673bd5..62beae8 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java
@@ -55,7 +55,7 @@
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
- System.out.println("COLLECTIONS " + node);
+
assert node.size() > 0;
}
@@ -69,20 +69,22 @@
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
assert node != null;
- System.out.println("JSON NODE RESULT " + node);
+
+ System.out.println("-------------------------------");
+ System.out.println("NODE COLLECTIONS" + node);
String id = node.path(0).path("id").asText();
response = resource().path(getAPIVersion()).path("collection").path(id)
.path("stats").header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
.get(ClientResponse.class);
- System.out.println("----------------------------- testStats 2");
- System.out.println(response.getEntity(String.class));
+
assert ClientResponse.Status.OK.getStatusCode() == response.getStatus();
node = JsonUtils.readTree(response.getEntity(String.class));
assert node != null;
int docs = node.path("documents").asInt();
- System.out.println("THE FINAL NODE : " + node);
+ System.out.println("-------------------------------");
+ System.out.println("NODE " + node);
assert docs > 0 && docs < 15;
}