Skip to content

Commit

Permalink
Regression fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
plyhun committed Sep 10, 2024
1 parent afb1b59 commit e6e4110
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTimeUtils;
import org.junit.After;
import org.junit.Test;
import org.mockito.Mockito;

Expand Down Expand Up @@ -43,17 +38,12 @@ public void testFirstApril() throws Exception {
}

@Test
public void testNonApril() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
Date secondApril = sdf.parse("02-01");
// always return the same time when querying current time
DateTimeUtils.setCurrentMillisFixed(secondApril.getTime());
String name = MeshNameProvider.getInstance().getRandomName();
assertFalse("We did not expect a skynet name but we got one {" + name + "}", name.indexOf("Skynet") > 0);
}
public void testNonApril() throws Exception {
LocalDate inputDate = LocalDate.of(2017, 4, 2);

@After
public void cleanUp() {
DateTimeUtils.setCurrentMillisSystem();
MeshNameProvider spy = Mockito.spy(new MeshNameProvider());
Mockito.when(spy.getDate()).thenReturn(inputDate);
String name = spy.getRandomName();
assertFalse("We did not expect a skynet name but we got one {" + name + "}", name.indexOf("Skynet") > 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public void testDefault() throws Exception {
// Same as both
setUp(null);

assertThat(metadata.get("subject")).isEqualTo("TestSubject");
assertThat(metadata.getMap()).hasSize(49);
assertThat(metadata.get("dc_subject")).isEqualTo("TestSubject");
assertThat(metadata.getMap()).hasSize(24);
assertThat(plainText).isEqualTo("Das ist ein Word Dokument für den Johannes");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("dc_subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("file").getString("content")).isEqualTo("Das ist ein Word Dokument für den Johannes");
}

Expand All @@ -104,10 +104,10 @@ public void testMetadata() throws Exception {
.setContent(false)
);

assertThat(metadata.get("subject")).isEqualTo("TestSubject");
assertThat(metadata.getMap()).hasSize(49);
assertThat(metadata.get("dc_subject")).isEqualTo("TestSubject");
assertThat(metadata.getMap()).hasSize(24);
assertThat(plainText).isNull();
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("dc_subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("file")).isNull();
}

Expand All @@ -131,10 +131,10 @@ public void testBoth() throws Exception {
.setContent(true)
);

assertThat(metadata.get("subject")).isEqualTo("TestSubject");
assertThat(metadata.getMap()).hasSize(49);
assertThat(metadata.get("dc_subject")).isEqualTo("TestSubject");
assertThat(metadata.getMap()).hasSize(24);
assertThat(plainText).isEqualTo("Das ist ein Word Dokument für den Johannes");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("dc_subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("file").getString("content")).isEqualTo("Das ist ein Word Dokument für den Johannes");
}

Expand All @@ -143,14 +143,14 @@ public void testWhitelist() throws Exception {
setUp(new BinaryExtractOptions()
.setMetadata(true)
.setContent(false)
, CollectionUtil.setOf("subject"));
, CollectionUtil.setOf("dc_subject"));

assertThat(metadata.get("subject")).isEqualTo("TestSubject");
assertThat(metadata.get("dc_subject")).isEqualTo("TestSubject");
assertThat(plainText).isNull();
assertThat(metadata.getLocation()).isNull();
assertThat(metadata.getMap()).hasSize(1);

assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("metadata").getString("dc_subject")).isEqualTo("TestSubject");
assertThat(document.getJsonObject("fields").getJsonObject("binary").getJsonObject("file")).isNull();
}
}

0 comments on commit e6e4110

Please sign in to comment.