Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fixed some failing unit tests on Windows #968

Merged
merged 3 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void testWriteMetrics() throws TimeoutException {
Assert.assertTrue(
MetricsTestUtil.isBetween(
MetricsTestUtil.getMeasurementFromList(writeTimeMeasurements, Statistic.TOTAL_TIME).getValue(),
0.5,
0.6));
0.45,
0.65));
}

@Test
Expand All @@ -91,8 +91,8 @@ public void testWriteAllMetrics() throws Exception {
Assert.assertTrue(
MetricsTestUtil.isBetween(
MetricsTestUtil.getMeasurementFromList(writeTimeMeasurements, Statistic.TOTAL_TIME).getValue(),
0.1,
0.2));
0.05,
0.25));
}

@Test
Expand Down Expand Up @@ -129,8 +129,8 @@ public void testReadMetrics() throws Exception {
Assert.assertEquals(1.0, MetricsTestUtil.getMeasurementFromList(readTimeMeasurements, Statistic.COUNT).getValue(), 0);
Assert.assertTrue(MetricsTestUtil.isBetween(
MetricsTestUtil.getMeasurementFromList(readTimeMeasurements, Statistic.TOTAL_TIME).getValue(),
0.1,
0.2));
0.05,
0.25));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PipelinesDataFlowModelTest {
void setup() {
objectMapper = new ObjectMapper(YAMLFactory.builder()
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
.enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS)
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
Expand Down Expand Up @@ -64,7 +65,7 @@ public final void testSerializingPluginModel_noExceptions() throws JsonGeneratio
public final void testSerialization_empty_plugin_to_YAML() throws JsonGenerationException, JsonMappingException, IOException {
final PluginModel pluginModel = new PluginModel("customPlugin", new HashMap<>());

final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS));

final String serialized = mapper.writeValueAsString(pluginModel);

Expand All @@ -78,7 +79,7 @@ public final void testSerialization_empty_plugin_to_YAML() throws JsonGeneration
public final void testUsingCustomSerializerWithPluginSettings_noExceptions() throws JsonGenerationException, JsonMappingException, IOException {
final PluginModel pluginModel = new PluginModel("customPlugin", validPluginSettings());

final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS));

final String serialized = mapper.writeValueAsString(pluginModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class DefaultEventMetadataTest {
Expand Down Expand Up @@ -92,8 +92,8 @@ public void testBuild_withoutTimeReceived() {
assertThat(result, notNullValue());
final Instant timeReceived = result.getTimeReceived();
assertThat(timeReceived, notNullValue());
assertThat(timeReceived, is(greaterThan(before)));
assertThat(timeReceived, is(lessThan(Instant.now())));
assertThat(timeReceived, is(greaterThanOrEqualTo(before)));
assertThat(timeReceived, is(lessThanOrEqualTo(Instant.now())));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public void testBuild_withAttributes() {
@Test
public void testBuild_withAllMetadataFields() {

final Instant now = Instant.now();
final Instant now = Instant.now().minusSeconds(1);
final Map<String, Object> testAttributes = new HashMap<>();
testAttributes.put(UUID.randomUUID().toString(), UUID.randomUUID());
testAttributes.put(UUID.randomUUID().toString(), UUID.randomUUID().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import java.nio.file.Paths;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -65,10 +67,12 @@ public void testGivenNullArgumentThenThrowException() {
public void testGivenLogstashConfigPathThenPipelineConfigCreated() {
final DataPrepperArgs args = new DataPrepperArgs(LOGSTASH_PIPELINE_FILE_PATH, DP_CONFIG_YAML_FILE_PATH);

final String configFileEnding = Paths.get("src", "test", "resources", "logstash-filter.yaml").toString();

assertThat(args, is(notNullValue()));
assertThat(
args.getPipelineConfigFileLocation(),
endsWith("src/test/resources/logstash-filter.yaml"));
endsWith(configFileEnding));
assertThat(args.getDataPrepperConfigFileLocation(), is(DP_CONFIG_YAML_FILE_PATH));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public String convertLogstashConfigurationToPipeline(String logstashConfiguratio
ObjectMapper mapper = new ObjectMapper(YAMLFactory.builder()
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
.enable(YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR)
.enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS)
.disable(YAMLGenerator.Feature.SPLIT_LINES)
.enable(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE)
.build());
Expand Down