Skip to content

Commit 65f7ea2

Browse files
committed
Rewrite this test
Assert that it's the sameInstance, and use an immutable map of immutable maps in order to be sure that nothing changed.
1 parent 96ff183 commit 65f7ea2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

modules/ingest-ecs/src/test/java/org/elasticsearch/ingest/ecs/EcsNamespaceProcessorTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import java.util.List;
1717
import java.util.Map;
1818

19+
import static java.util.Map.entry;
20+
import static org.hamcrest.Matchers.sameInstance;
21+
1922
public class EcsNamespaceProcessorTests extends ESTestCase {
2023

2124
private final EcsNamespaceProcessor processor = new EcsNamespaceProcessor("test", "test processor");
@@ -111,18 +114,15 @@ public void testIsOTelDocument_validBody() {
111114
}
112115

113116
public void testExecute_validOTelDocument() {
114-
Map<String, Object> source = new HashMap<>();
115-
source.put("resource", new HashMap<>());
116-
source.put("scope", new HashMap<>());
117-
Map<String, Object> body = new HashMap<>();
118-
body.put("text", "a string");
119-
body.put("structured", new HashMap<>());
120-
source.put("body", body);
121-
source.put("key1", "value1");
122-
Map<String, Object> before = new HashMap<>(source);
117+
Map<String, Object> source = Map.ofEntries(
118+
entry("resource", Map.of()),
119+
entry("scope", Map.of()),
120+
entry("body", Map.of("text", "a string", "structured", Map.of())),
121+
entry("key1", "value1")
122+
);
123123
IngestDocument document = new IngestDocument("index", "id", 1, null, null, source);
124124
processor.execute(document);
125-
assertEquals(before, document.getSource());
125+
assertThat(source, sameInstance(document.getSource()));
126126
}
127127

128128
public void testExecute_nonOTelDocument() {

0 commit comments

Comments
 (0)