Skip to content

Commit

Permalink
Closes #300: adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jendib committed May 21, 2019
1 parent ab8176e commit 82d788c
Showing 1 changed file with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,9 @@ public void testEmlImport() throws Exception {

/**
* Test custom metadata.
*
* @throws Exception e
*/
@Test
public void testCustomMetadata() throws Exception {
public void testCustomMetadata() {
// Login admin
String adminToken = clientUtil.login("admin", "admin", false);

Expand Down Expand Up @@ -895,12 +893,12 @@ public void testCustomMetadata() throws Exception {
Assert.assertEquals(metadataIntId, meta.getString("id"));
Assert.assertEquals("1int", meta.getString("name"));
Assert.assertEquals("INTEGER", meta.getString("type"));
Assert.assertEquals("50", meta.getString("value"));
Assert.assertEquals(50, meta.getInt("value"));
meta = metadata.getJsonObject(2);
Assert.assertEquals(metadataFloatId, meta.getString("id"));
Assert.assertEquals("2float", meta.getString("name"));
Assert.assertEquals("FLOAT", meta.getString("type"));
Assert.assertEquals("12.4", meta.getString("value"));
Assert.assertEquals(12.4, meta.getJsonNumber("value").doubleValue(), 0);
meta = metadata.getJsonObject(3);
Assert.assertEquals(metadataDateId, meta.getString("id"));
Assert.assertEquals("3date", meta.getString("name"));
Expand All @@ -913,7 +911,7 @@ public void testCustomMetadata() throws Exception {
Assert.assertFalse(meta.containsKey("value"));

// Update the document with metadata1 (add more metadata)
String dateValue = Long.toString(new Date().getTime());
long dateValue = new Date().getTime();
target().path("/document/" + document1Id).request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, metadata1Token)
.post(Entity.form(new Form()
Expand All @@ -927,7 +925,7 @@ public void testCustomMetadata() throws Exception {
.param("metadata_value", "my string 2")
.param("metadata_value", "52")
.param("metadata_value", "14.4")
.param("metadata_value", dateValue)
.param("metadata_value", Long.toString(dateValue))
.param("metadata_value", "true")), JsonObject.class);

// Check the values
Expand All @@ -945,22 +943,22 @@ public void testCustomMetadata() throws Exception {
Assert.assertEquals(metadataIntId, meta.getString("id"));
Assert.assertEquals("1int", meta.getString("name"));
Assert.assertEquals("INTEGER", meta.getString("type"));
Assert.assertEquals("52", meta.getString("value"));
Assert.assertEquals(52, meta.getInt("value"));
meta = metadata.getJsonObject(2);
Assert.assertEquals(metadataFloatId, meta.getString("id"));
Assert.assertEquals("2float", meta.getString("name"));
Assert.assertEquals("FLOAT", meta.getString("type"));
Assert.assertEquals("14.4", meta.getString("value"));
Assert.assertEquals(14.4, meta.getJsonNumber("value").doubleValue(), 0);
meta = metadata.getJsonObject(3);
Assert.assertEquals(metadataDateId, meta.getString("id"));
Assert.assertEquals("3date", meta.getString("name"));
Assert.assertEquals("DATE", meta.getString("type"));
Assert.assertEquals(dateValue, meta.getString("value"));
Assert.assertEquals(dateValue, meta.getJsonNumber("value").longValue());
meta = metadata.getJsonObject(4);
Assert.assertEquals(metadataBoolId, meta.getString("id"));
Assert.assertEquals("4bool", meta.getString("name"));
Assert.assertEquals("BOOLEAN", meta.getString("type"));
Assert.assertEquals("true", meta.getString("value"));
Assert.assertTrue(meta.getBoolean("value"));

// Update the document with metadata1 (remove some metadata)
target().path("/document/" + document1Id).request()
Expand All @@ -972,7 +970,7 @@ public void testCustomMetadata() throws Exception {
.param("metadata_id", metadataDateId)
.param("metadata_id", metadataBoolId)
.param("metadata_value", "14.4")
.param("metadata_value", dateValue)
.param("metadata_value", Long.toString(dateValue))
.param("metadata_value", "true")), JsonObject.class);

// Check the values
Expand All @@ -985,26 +983,26 @@ public void testCustomMetadata() throws Exception {
Assert.assertEquals(metadataStrId, meta.getString("id"));
Assert.assertEquals("0str", meta.getString("name"));
Assert.assertEquals("STRING", meta.getString("type"));
Assert.assertTrue(meta.isNull("value"));
Assert.assertFalse(meta.containsKey("value"));
meta = metadata.getJsonObject(1);
Assert.assertEquals(metadataIntId, meta.getString("id"));
Assert.assertEquals("1int", meta.getString("name"));
Assert.assertEquals("INTEGER", meta.getString("type"));
Assert.assertTrue(meta.isNull("value"));
Assert.assertFalse(meta.containsKey("value"));
meta = metadata.getJsonObject(2);
Assert.assertEquals(metadataFloatId, meta.getString("id"));
Assert.assertEquals("2float", meta.getString("name"));
Assert.assertEquals("FLOAT", meta.getString("type"));
Assert.assertEquals("14.4", meta.getString("value"));
Assert.assertEquals(14.4, meta.getJsonNumber("value").doubleValue(), 0);
meta = metadata.getJsonObject(3);
Assert.assertEquals(metadataDateId, meta.getString("id"));
Assert.assertEquals("3date", meta.getString("name"));
Assert.assertEquals("DATE", meta.getString("type"));
Assert.assertEquals(dateValue, meta.getString("value"));
Assert.assertEquals(dateValue, meta.getJsonNumber("value").longValue());
meta = metadata.getJsonObject(4);
Assert.assertEquals(metadataBoolId, meta.getString("id"));
Assert.assertEquals("4bool", meta.getString("name"));
Assert.assertEquals("BOOLEAN", meta.getString("type"));
Assert.assertEquals("true", meta.getString("value"));
Assert.assertTrue(meta.getBoolean("value"));
}
}

0 comments on commit 82d788c

Please sign in to comment.