diff --git a/core/common-util/src/test/java/uk/gov/gchq/gaffer/commonutil/elementvisibilityutil/AuthorisationsTest.java b/core/common-util/src/test/java/uk/gov/gchq/gaffer/commonutil/elementvisibilityutil/AuthorisationsTest.java index 7fc9fefd53e..3edc071e6a9 100644 --- a/core/common-util/src/test/java/uk/gov/gchq/gaffer/commonutil/elementvisibilityutil/AuthorisationsTest.java +++ b/core/common-util/src/test/java/uk/gov/gchq/gaffer/commonutil/elementvisibilityutil/AuthorisationsTest.java @@ -113,7 +113,8 @@ void testUnmodifiableList() { @Test void testToString() { final Authorisations a = new Authorisations("a", "abcdefg", "hijklmno"); - - assertThat(a).hasToString("a,hijklmno,abcdefg"); + assertThat(a.toString()).contains("a"); + assertThat(a.toString()).contains("abcdefg"); + assertThat(a.toString()).contains("hijklmno"); } } diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewTest.java index db63733bf74..b21ccd18244 100644 --- a/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewTest.java +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 Crown Copyright + * Copyright 2016-2024 Crown Copyright * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package uk.gov.gchq.gaffer.data.elementdefinition.view; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; import uk.gov.gchq.gaffer.JSONSerialisationTest; @@ -30,6 +32,7 @@ import uk.gov.gchq.koryphe.impl.function.Identity; import uk.gov.gchq.koryphe.impl.predicate.Exists; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -384,7 +387,7 @@ public void shouldCreateViewWithGlobalDefinitions() { } @Test - public void shouldCreateAnIdenticalObjectWhenCloned() { + public void shouldCreateAnIdenticalObjectWhenCloned() throws IOException { // Given final ViewElementDefinition edgeDef1 = new ViewElementDefinition(); final ViewElementDefinition edgeDef2 = new ViewElementDefinition(); @@ -408,8 +411,11 @@ public void shouldCreateAnIdenticalObjectWhenCloned() { final byte[] viewJson = view.toCompactJson(); final byte[] cloneJson = clone.toCompactJson(); + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode treeView = objectMapper.readTree(viewJson); + JsonNode treeClone = objectMapper.readTree(cloneJson); // Check that JSON representations of the objects are equal - assertThat(cloneJson).containsExactly(viewJson); + assertThat(treeClone).isEqualTo(treeView); final View viewFromJson = new View.Builder().json(viewJson).build(); final View cloneFromJson = new View.Builder().json(cloneJson).build(); diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewUtilTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewUtilTest.java index 8bed1b0f3e6..6affeeffb27 100644 --- a/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewUtilTest.java +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/elementdefinition/view/ViewUtilTest.java @@ -16,6 +16,8 @@ package uk.gov.gchq.gaffer.data.elementdefinition.view; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; import uk.gov.gchq.gaffer.commonutil.JsonAssert; @@ -29,6 +31,7 @@ import uk.gov.gchq.gaffer.function.ExampleTransformFunction; import uk.gov.gchq.koryphe.impl.predicate.Exists; +import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -36,7 +39,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; @@ -497,7 +499,7 @@ public void shouldCreateViewWithGlobalDefinitions() { } @Test - public void shouldCreateAnIdenticalObjectWhenCloned() { + public void shouldCreateAnIdenticalObjectWhenCloned() throws IOException{ // Given final ViewElementDefinition edgeDef1 = new ViewElementDefinition(); final ViewElementDefinition edgeDef2 = new ViewElementDefinition(); @@ -521,8 +523,13 @@ public void shouldCreateAnIdenticalObjectWhenCloned() { final byte[] viewJson = view.toCompactJson(); final byte[] cloneJson = clone.toCompactJson(); + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode treeView = objectMapper.readTree(viewJson); + JsonNode treeClone = objectMapper.readTree(cloneJson); + // Check that JSON representations of the objects are equal - assertArrayEquals(viewJson, cloneJson); + assertThat(treeView).isEqualTo(treeClone); + final View viewFromJson = new View.Builder().json(viewJson).build(); final View cloneFromJson = new View.Builder().json(cloneJson).build();