diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index afa74d3ed8c..aa3f904c19c 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -21,7 +21,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: '8' + java-version: '11' - name: Cache dependencies uses: actions/cache@v4 diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index b454c1a0e6e..f4cb09f5a46 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -33,7 +33,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: '8' + java-version: '11' - name: Run Spotless copyright check run: mvn -ntp spotless:check -T0.5C @@ -134,7 +134,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: '8' + java-version: '11' - name: Cache dependencies uses: actions/cache@v4 diff --git a/.gitignore b/.gitignore index 2e22cd36844..549b2c0e494 100755 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ example/real-federated-store/*.properties example/real-federated-store/*.json example/real-federated-store/*.jar .flattened-pom.xml +dependency-reduced-pom.xml diff --git a/core/common-util/pom.xml b/core/common-util/pom.xml index 36dd693b4c1..cf40f68aaa3 100644 --- a/core/common-util/pom.xml +++ b/core/common-util/pom.xml @@ -46,7 +46,7 @@ uk.gov.gchq.koryphe core - jdk8 + ${koryphe.classifer} diff --git a/core/data/pom.xml b/core/data/pom.xml index 794f2f1b275..73b83fcf3c4 100644 --- a/core/data/pom.xml +++ b/core/data/pom.xml @@ -29,7 +29,7 @@ uk.gov.gchq.koryphe core - jdk8 + ${koryphe.classifer} uk.gov.gchq.gaffer @@ -67,7 +67,7 @@ uk.gov.gchq.koryphe core - tests-jdk8 + ${koryphe.test.classifer} test-jar test diff --git a/core/operation/pom.xml b/core/operation/pom.xml index 7ff19df5b64..df388d4f23a 100644 --- a/core/operation/pom.xml +++ b/core/operation/pom.xml @@ -58,7 +58,7 @@ uk.gov.gchq.koryphe core - tests-jdk8 + ${koryphe.test.classifer} test-jar test diff --git a/core/store/src/test/java/uk/gov/gchq/gaffer/store/StoreTest.java b/core/store/src/test/java/uk/gov/gchq/gaffer/store/StoreTest.java index 2eaafd8c112..61f0a6e1260 100644 --- a/core/store/src/test/java/uk/gov/gchq/gaffer/store/StoreTest.java +++ b/core/store/src/test/java/uk/gov/gchq/gaffer/store/StoreTest.java @@ -616,7 +616,8 @@ public void shouldReturnAllSupportedOperationsWhenJobTrackerIsEnabled(@Mock fina expectedOperations.sort(Comparator.comparing(Class::getName)); supportedOperations.sort(Comparator.comparing(Class::getName)); - assertThat(supportedOperations).isEqualTo(expectedOperations); + Set> dedupedExpected = new HashSet<>(expectedOperations); + assertThat(supportedOperations).containsExactlyInAnyOrderElementsOf(dedupedExpected); } @Test @@ -724,7 +725,8 @@ public void shouldReturnAllSupportedOperationsWhenJobTrackerIsDisabled(@Mock fin expectedOperations.sort(Comparator.comparing(Class::getName)); supportedOperations.sort(Comparator.comparing(Class::getName)); - assertThat(supportedOperations).isEqualTo(expectedOperations); + Set> dedupedExpected = new HashSet<>(expectedOperations); + assertThat(supportedOperations).containsExactlyInAnyOrderElementsOf(dedupedExpected); } @Test diff --git a/core/type/pom.xml b/core/type/pom.xml index 04f82cef686..c16edb2a71d 100644 --- a/core/type/pom.xml +++ b/core/type/pom.xml @@ -34,14 +34,14 @@ uk.gov.gchq.koryphe core - jdk8 + ${koryphe.classifer} uk.gov.gchq.koryphe core - tests-jdk8 + ${koryphe.test.classifer} test-jar test diff --git a/example/basic/basic-model/pom.xml b/example/basic/basic-model/pom.xml index 36284c047c3..c71751b4f21 100644 --- a/example/basic/basic-model/pom.xml +++ b/example/basic/basic-model/pom.xml @@ -31,11 +31,6 @@ data ${project.parent.version} - - uk.gov.gchq.gaffer - sketches-library - ${project.parent.version} - uk.gov.gchq.gaffer @@ -68,6 +63,18 @@ accumulo-minicluster test + + uk.gov.gchq.gaffer + sketches-library + ${project.parent.version} + test + + + uk.gov.gchq.gaffer + hdfs-library + ${project.parent.version} + test + org.apache.hadoop hadoop-hdfs diff --git a/example/road-traffic/road-traffic-generators/pom.xml b/example/road-traffic/road-traffic-generators/pom.xml index ae9569a4a75..58ba7e38d1b 100644 --- a/example/road-traffic/road-traffic-generators/pom.xml +++ b/example/road-traffic/road-traffic-generators/pom.xml @@ -51,6 +51,11 @@ commons-csv ${commons-csv.version} + + org.apache.datasketches + datasketches-java + ${datasketches.version} + uk.gov.gchq.gaffer @@ -77,6 +82,12 @@ accumulo-minicluster test + + uk.gov.gchq.gaffer + hdfs-library + ${project.parent.version} + test + org.apache.hadoop hadoop-hdfs diff --git a/example/road-traffic/road-traffic-model/pom.xml b/example/road-traffic/road-traffic-model/pom.xml index fee9fada104..3cab4031c4b 100644 --- a/example/road-traffic/road-traffic-model/pom.xml +++ b/example/road-traffic/road-traffic-model/pom.xml @@ -63,6 +63,12 @@ test-jar test + + uk.gov.gchq.gaffer + hdfs-library + ${project.parent.version} + test + uk.gov.gchq.gaffer hdfs-library diff --git a/example/road-traffic/road-traffic-rest/pom.xml b/example/road-traffic/road-traffic-rest/pom.xml index b126abebdfe..f3f3a74d161 100644 --- a/example/road-traffic/road-traffic-rest/pom.xml +++ b/example/road-traffic/road-traffic-rest/pom.xml @@ -122,6 +122,18 @@ hadoop-hdfs test + + com.clearspring.analytics + stream + ${clearspring.version} + test + + + org.apache.datasketches + datasketches-java + ${datasketches.version} + test + diff --git a/integration-test/pom.xml b/integration-test/pom.xml index 8e30d4bff88..5c36ba7ad49 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -38,6 +38,27 @@ graph ${project.parent.version} + + org.junit.jupiter + junit-jupiter + ${junit.version} + + + org.junit.platform + junit-platform-suite + ${junit-platform.version} + + + org.junit.platform + junit-platform-suite-api + ${junit-platform.version} + + + org.junit.platform + junit-platform-commons + ${junit-platform.version} + + uk.gov.gchq.gaffer common-util @@ -56,35 +77,10 @@ ${project.parent.version} test-jar - - org.junit.platform - junit-platform-suite - - - org.junit.jupiter - junit-jupiter - ${junit.version} - provided - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - provided - - - org.assertj - assertj-core - ${assertj.version} - provided - - - - org.junit.platform junit-platform-testkit - ${junit-suite.version} + ${junit-platform.version} test diff --git a/integration-test/src/main/java/uk/gov/gchq/gaffer/integration/junit/extensions/IntegrationTestSuiteExtension.java b/integration-test/src/main/java/uk/gov/gchq/gaffer/integration/junit/extensions/IntegrationTestSuiteExtension.java index 4a0fd9d910f..2b91047775f 100644 --- a/integration-test/src/main/java/uk/gov/gchq/gaffer/integration/junit/extensions/IntegrationTestSuiteExtension.java +++ b/integration-test/src/main/java/uk/gov/gchq/gaffer/integration/junit/extensions/IntegrationTestSuiteExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Crown Copyright + * Copyright 2022-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. @@ -32,6 +32,7 @@ import uk.gov.gchq.gaffer.store.schema.Schema; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -41,7 +42,6 @@ import static org.junit.platform.commons.support.ReflectionSupport.tryToLoadClass; import static org.junit.platform.commons.util.AnnotationUtils.findAnnotatedFields; -import static org.junit.platform.commons.util.ReflectionUtils.makeAccessible; import static org.junit.platform.commons.util.ReflectionUtils.newInstance; /** @@ -271,8 +271,11 @@ private void injectInstanceFields(final Object instance) { LOGGER.debug("Field [{}] requires injecting", annotatedField); final Object object = getObject(annotatedField.getType()); LOGGER.debug("Object [{}] found for the field", object); - makeAccessible(annotatedField).set(instance, object); - } catch (final Throwable t) { + if (!Modifier.isPublic(annotatedField.getModifiers()) || !Modifier.isPublic(annotatedField.getDeclaringClass().getModifiers())) { + annotatedField.setAccessible(true); + annotatedField.set(instance, object); + } + } catch (final Exception t) { throw new RuntimeException("Error accessing the field object", t); } } diff --git a/library/bitmap-library/pom.xml b/library/bitmap-library/pom.xml index 1ffc9f9c7f9..fe7094f7344 100644 --- a/library/bitmap-library/pom.xml +++ b/library/bitmap-library/pom.xml @@ -24,6 +24,7 @@ 4.0.0 bitmap-library + ${revision} @@ -34,7 +35,7 @@ uk.gov.gchq.koryphe core - jdk8 + ${koryphe.classifer} org.roaringbitmap @@ -45,7 +46,7 @@ uk.gov.gchq.koryphe core - tests-jdk8 + ${koryphe.test.classifer} test-jar test diff --git a/library/hdfs-library/pom.xml b/library/hdfs-library/pom.xml index 10627c38a59..5137515de90 100644 --- a/library/hdfs-library/pom.xml +++ b/library/hdfs-library/pom.xml @@ -24,6 +24,7 @@ hdfs-library + ${revision} diff --git a/library/sketches-library/pom.xml b/library/sketches-library/pom.xml index 51a27aff5d5..7b888bd8e87 100644 --- a/library/sketches-library/pom.xml +++ b/library/sketches-library/pom.xml @@ -24,6 +24,7 @@ sketches-library + ${revision} @@ -39,7 +40,7 @@ uk.gov.gchq.koryphe core - jdk8 + ${koryphe.classifer} com.clearspring.analytics @@ -56,7 +57,7 @@ uk.gov.gchq.koryphe core - tests-jdk8 + ${koryphe.test.classifer} test-jar test @@ -88,10 +89,9 @@ shade - true - - deploy - + true + deploy + false com.clearspring.analytics:stream diff --git a/library/spark/spark-accumulo-library/pom.xml b/library/spark/spark-accumulo-library/pom.xml index 4725a3b8ffa..0023e201deb 100644 --- a/library/spark/spark-accumulo-library/pom.xml +++ b/library/spark/spark-accumulo-library/pom.xml @@ -40,6 +40,56 @@ sketches-library ${project.parent.version} + + org.apache.accumulo + accumulo-core + ${accumulo.version} + + + + org.apache.hadoop + hadoop-hdfs + + + org.apache.avro + avro-ipc + + + com.sun.jersey + jersey-client + + + com.sun.jersey.jersey-test-framework + jersey-test-framework-grizzly2 + + + com.sun.jersey + jersey-server + + + com.sun.jersey + jersey-json + + + com.sun.jersey.contribs + jersey-guice + + + io.netty + netty + + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + @@ -84,6 +134,12 @@ test test-jar + + uk.gov.gchq.gaffer + hdfs-library + ${project.parent.version} + test + org.apache.accumulo accumulo-minicluster diff --git a/library/spark/spark-library/pom.xml b/library/spark/spark-library/pom.xml index ca12edf02a4..6ad8ea7be3d 100644 --- a/library/spark/spark-library/pom.xml +++ b/library/spark/spark-library/pom.xml @@ -129,6 +129,11 @@ graphframes ${graphframes.version} + + org.apache.datasketches + datasketches-java + ${datasketches.version} + diff --git a/library/time-library/pom.xml b/library/time-library/pom.xml index b2b02193ba3..8bdd6fdefd6 100644 --- a/library/time-library/pom.xml +++ b/library/time-library/pom.xml @@ -24,36 +24,47 @@ time-library + ${revision} uk.gov.gchq.gaffer bitmap-library - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer sketches-library - ${project.parent.version} + ${project.version} + + + org.roaringbitmap + RoaringBitmap + 0.5.11 + + + org.apache.datasketches + datasketches-java + ${datasketches.version} uk.gov.gchq.gaffer serialisation - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer common-util - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.koryphe core - tests-jdk8 + ${koryphe.test.classifer} test-jar test diff --git a/library/tinkerpop/pom.xml b/library/tinkerpop/pom.xml index 645ec6d4963..a96908a07ca 100644 --- a/library/tinkerpop/pom.xml +++ b/library/tinkerpop/pom.xml @@ -38,7 +38,7 @@ uk.gov.gchq.gaffer graph - ${project.parent.version} + ${project.version} @@ -63,25 +63,25 @@ uk.gov.gchq.gaffer accumulo-store - ${project.parent.version} + ${project.version} runtime uk.gov.gchq.gaffer map-store - ${project.parent.version} + ${project.version} runtime uk.gov.gchq.gaffer proxy-store - ${project.parent.version} + ${project.version} runtime uk.gov.gchq.gaffer jcs-cache-service - ${project.parent.version} + ${project.version} runtime @@ -89,7 +89,7 @@ uk.gov.gchq.gaffer accumulo-store - ${project.parent.version} + ${project.version} test-jar test @@ -98,10 +98,16 @@ accumulo-minicluster test + + uk.gov.gchq.gaffer + hdfs-library + ${project.version} + test + uk.gov.gchq.gaffer common-util - ${project.parent.version} + ${project.version} test-jar test diff --git a/pom.xml b/pom.xml index dca3aecbdfd..f805e59edf1 100644 --- a/pom.xml +++ b/pom.xml @@ -49,29 +49,32 @@ package + + tests - 1.8 + 11 - 5.9.3 - 1.9.3 - 3.24.2 - 4.11.0 + 5.10.3 + 1.10.3 + 3.26.3 + 5.12.0 + 5.2.0 1.7.36 - 2.11 - ${scala.minor.version}.12 - 2.4 - ${spark.minor.version}.5 + 2.12 + ${scala.minor.version}.15 + 3.0 + ${spark.minor.version}.3 2.5.2 2.0.1 1.8.2 3.3.3 - 2.13.5 + 2.17.2 - 2.7.0 - 4.0.0 + 2.9.8 + 6.0.0 1.15 2.11.0 3.12.0 @@ -82,7 +85,7 @@ 4.4 1.10.0 2.13.0 - 30.1.1-jre + 33.2.1-jre 3.29.2-GA 1.1.1 1.3.2 @@ -99,8 +102,7 @@ 5.15.0 1.36.0 3.7.1 - - 1.0.0 + 1.0.4 2.17 @@ -122,15 +124,16 @@ 1.6.8 3.0.0-M5 3.1.0 - 3.2.4 + 3.6.0 3.2.1 - 3.1.2 + 3.3.1 3.1.2 1.9.10 3.1.0 3.12.1 3.4.1 1.5.0 + 10.0.3 @@ -186,13 +189,13 @@ uk.gov.gchq.koryphe core ${koryphe.version} - jdk8 + ${koryphe.classifer} uk.gov.gchq.koryphe core ${koryphe.version} - tests-jdk8 + ${koryphe.test.classifer} test-jar test @@ -206,6 +209,11 @@ jackson-core ${jackson.version} + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + com.fasterxml.jackson.dataformat jackson-dataformat-xml @@ -744,7 +752,17 @@ org.junit.platform junit-platform-suite - ${junit-suite.version} + ${junit-platform.version} + + + org.junit.platform + junit-platform-suite-api + ${junit-platform.version} + + + org.junit.platform + junit-platform-commons + ${junit-platform.version} org.glassfish.jersey.containers @@ -839,6 +857,11 @@ + + org.owasp + dependency-check-maven + ${dependency-check.plugin.version} + org.apache.maven.plugins maven-release-plugin @@ -1636,92 +1659,56 @@ + 1.8 legacy -legacy + jdk8 + tests-jdk8 1.9.3 2.6.5 13.0.1 + 2.13.5 + 2.7.0 + 4.0.0 + 1.0.0 + + 2.4 + ${spark.minor.version}.5 + 2.11 + ${scala.minor.version}.12 + + 5.9.3 + 1.9.3 + 3.24.2 + 4.11.0 + 4.11.0 2.5.2 + 3.2.4 org.apache.maven.plugins - maven-war-plugin + maven-compiler-plugin + ${compiler.plugin.verson} - ${war.classifier} + ${java.version} + ${java.version} - - - - - - java11 - - 11 - - - 11 - 3.0 - ${spark.minor.version}.3 - 2.12 - ${scala.minor.version}.15 - - - - org.apache.maven.plugins - maven-compiler-plugin - ${compiler.plugin.verson} + maven-war-plugin - ${java.version} + ${war.classifier} - - - org.apache.maven.plugins - maven-javadoc-plugin - ${javadoc.plugin.version} - - - --frames - - - - - org.apache.maven.plugins - maven-enforcer-plugin - ${enforcer.plugin.version} - - - enforce-compatible-hadoop - - enforce - - - - - - org.apache.hadoop:*:(,2.9.9] - - - Hadoop versions below 3.3.0 are incompatible with JDK 11, JDK 8 must be used with the legacy profile - - - - - - - - diff --git a/rest-api/common-rest/pom.xml b/rest-api/common-rest/pom.xml index e6e299312d0..749c17cc4d4 100644 --- a/rest-api/common-rest/pom.xml +++ b/rest-api/common-rest/pom.xml @@ -41,11 +41,12 @@ uk.gov.gchq.gaffer map-store ${project.parent.version} + test uk.gov.gchq.koryphe core - tests-jdk8 + ${koryphe.test.classifer} test-jar test diff --git a/rest-api/spring-rest/pom.xml b/rest-api/spring-rest/pom.xml index 085e10e198a..2c37a360e05 100644 --- a/rest-api/spring-rest/pom.xml +++ b/rest-api/spring-rest/pom.xml @@ -26,7 +26,7 @@ spring-rest - 2.7.12 + 2.7.18 1.6.15 map @@ -36,56 +36,61 @@ uk.gov.gchq.gaffer common-rest - ${project.parent.version} + ${project.version} + + + uk.gov.gchq.gaffer + serialisation + ${project.version} uk.gov.gchq.gaffer time-library - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer bitmap-library - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer sketches-library - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer jcs-cache-service - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer tinkerpop - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer map-store - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer federated-store - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer accumulo-store - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer proxy-store - ${project.parent.version} + ${project.version} @@ -146,13 +151,19 @@ junit-jupiter-engine test + + org.junit.platform + junit-platform-launcher + test + uk.gov.gchq.gaffer tinkerpop - ${project.parent.version} + ${project.version} test-jar test + org.apache.tinkerpop gremlin-driver diff --git a/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/config/JsonSerialisationConfigIT.java b/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/config/JsonSerialisationConfigIT.java index 990be1d801d..d26ae573b00 100644 --- a/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/config/JsonSerialisationConfigIT.java +++ b/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/config/JsonSerialisationConfigIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Crown Copyright + * Copyright 2020-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. @@ -21,40 +21,73 @@ import org.apache.datasketches.hll.HllSketch; import org.assertj.core.data.Percentage; +import org.json.JSONArray; +import org.json.JSONObject; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.TestPropertySource; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import uk.gov.gchq.gaffer.commonutil.StreamUtil; import uk.gov.gchq.gaffer.data.element.Entity; -import uk.gov.gchq.gaffer.data.elementdefinition.view.View; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; import uk.gov.gchq.gaffer.mapstore.MapStoreProperties; -import uk.gov.gchq.gaffer.operation.OperationException; import uk.gov.gchq.gaffer.operation.impl.add.AddElements; -import uk.gov.gchq.gaffer.operation.impl.get.GetElements; import uk.gov.gchq.gaffer.rest.factory.GraphFactory; -import uk.gov.gchq.gaffer.rest.integration.controller.AbstractRestApiIT; +import uk.gov.gchq.gaffer.rest.factory.spring.AbstractUserFactory; +import uk.gov.gchq.gaffer.rest.factory.spring.UnknownUserFactory; import uk.gov.gchq.gaffer.sketches.serialisation.json.SketchesJsonModules; import uk.gov.gchq.gaffer.store.StoreProperties; import uk.gov.gchq.gaffer.user.User; -import java.util.List; -import java.util.Map; +import javax.ws.rs.core.MediaType; import static org.assertj.core.api.Assertions.assertThat; -@TestPropertySource( - properties = "gaffer.graph.factory.class=uk.gov.gchq.gaffer.rest.integration.config.JsonSerialisationConfigIT$SerialisationGraphFactory" -) -public class JsonSerialisationConfigIT extends AbstractRestApiIT { +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@Import(JsonSerialisationConfigIT.TestConfig.class) +@ActiveProfiles("test") +class JsonSerialisationConfigIT { + + @TestConfiguration + static class TestConfig { + + @Bean + @Primary + @Profile("test") + public GraphFactory createTestGraphFactory() { + return new SerialisationGraphFactory(); + } + + @Bean + @Profile("test") + public AbstractUserFactory userFactory() { + return new UnknownUserFactory(); + } + } + @Autowired private GraphFactory graphFactory; + @Autowired + private MockMvc mockMvc; + @Test - public void shouldSerialiseHyperLogLogPlussesWhenSerialiserModulesConfigured() throws OperationException { + public void shouldSerialiseHyperLogLogPlussesWhenSerialiserModulesConfigured() throws Exception { // Given final HyperLogLogPlus hllp = new HyperLogLogPlus(5, 5); hllp.offer(1); @@ -68,25 +101,44 @@ public void shouldSerialiseHyperLogLogPlussesWhenSerialiserModulesConfigured() t .build()) .build(), new User()); + final JSONObject expectedHllpProperty = new JSONObject() + .put("com.clearspring.analytics.stream.cardinality.HyperLogLogPlus", new JSONObject() + .put("hyperLogLogPlus", new JSONObject() + .put("hyperLogLogPlusSketchBytes", "/////gUFAQL7C4AJ") + .put("cardinality", 2))); + // When - final GetElements getElements = new GetElements.Builder() - .input("vertex1") - .view(new View.Builder() - .entity("CardinalityHllp") - .build()) - .build(); - final ResponseEntity elements = post("/graph/operations/execute", getElements, List.class); - final Map result = ((List>) elements.getBody()).get(0); - final Map hllpJson = ((Map>>>) result.get("properties")).get("hllp").get(HyperLogLogPlus.class.getName()).get("hyperLogLogPlus"); - - assertThat(hllpJson) - .isNotNull() - .containsKey("cardinality") - .containsEntry("cardinality", 2); + final JSONObject jsonQuery = new JSONObject() + .put("class", "GetElements") + .put("input", new JSONArray() + .put(new JSONObject() + .put("class", "EntitySeed") + .put("vertex", "vertex1"))) + .put("view", new JSONObject() + .put("entities", new JSONObject() + .put("CardinalityHllp", new JSONObject()))); + + + // When + MvcResult result = mockMvc + .perform(MockMvcRequestBuilders + .post("/rest/graph/operations/execute") + .content(jsonQuery.toString()) + .contentType(MediaType.APPLICATION_JSON)) + .andReturn(); + + assertThat(result.getResponse().getStatus()).isEqualTo(200); + + // Get and check response + JSONArray jsonResponse = new JSONArray(result.getResponse().getContentAsString()); + + assertThat(jsonResponse).hasSize(1); + JSONObject hllpProp = jsonResponse.getJSONObject(0).getJSONObject("properties").getJSONObject("hllp"); + assertThat(hllpProp.toMap()).isEqualTo(expectedHllpProperty.toMap()); } @Test - public void shouldSerialiseHllSketchWhenSerialiserModulesConfigured() throws OperationException { + public void shouldSerialiseHllSketchWhenSerialiserModulesConfigured() throws Exception { // Given final HllSketch hllSketch = new HllSketch(10); hllSketch.update(1); @@ -101,21 +153,39 @@ public void shouldSerialiseHllSketchWhenSerialiserModulesConfigured() throws Ope .build(), new User()); // When - final GetElements getElements = new GetElements.Builder() - .input("vertex1") - .view(new View.Builder() - .entity("CardinalityHllSketch") - .build()) - .build(); - final ResponseEntity elements = post("/graph/operations/execute", getElements, List.class); - final Map result = ((List>) elements.getBody()).get(0); - final Map hllSketchJson = ((Map>>) result.get("properties")).get("hllSketch").get(HllSketch.class.getName()); - - assertThat(hllSketchJson) - .isNotNull() - .containsKey("cardinality"); - - assertThat((double) hllSketchJson.get("cardinality")).isCloseTo(2, Percentage.withPercentage(0.001)); + final JSONObject jsonQuery = new JSONObject() + .put("class", "GetElements") + .put("input", new JSONArray() + .put(new JSONObject() + .put("class", "EntitySeed") + .put("vertex", "vertex1"))) + .put("view", new JSONObject() + .put("entities", new JSONObject() + .put("CardinalityHllSketch", new JSONObject()))); + + // When + MvcResult result = mockMvc + .perform(MockMvcRequestBuilders + .post("/rest/graph/operations/execute") + .content(jsonQuery.toString()) + .contentType(MediaType.APPLICATION_JSON)) + .andReturn(); + + // When + assertThat(result.getResponse().getStatus()).isEqualTo(200); + + // Get and check response + JSONArray jsonResponse = new JSONArray(result.getResponse().getContentAsString()); + + assertThat(jsonResponse).hasSize(1); + + JSONObject hllpSketch = jsonResponse.getJSONObject(0) + .getJSONObject("properties") + .getJSONObject("hllSketch") + .getJSONObject(HllSketch.class.getName()); + + assertThat(hllpSketch.toMap()).containsKey("cardinality"); + assertThat(hllpSketch.getDouble("cardinality")).isCloseTo(2, Percentage.withPercentage(0.001)); } diff --git a/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/controller/AbstractRestApiIT.java b/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/controller/AbstractRestApiIT.java index f8274cc8d68..6e54b66c746 100644 --- a/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/controller/AbstractRestApiIT.java +++ b/rest-api/spring-rest/src/test/java/uk/gov/gchq/gaffer/rest/integration/controller/AbstractRestApiIT.java @@ -87,7 +87,7 @@ protected String getContextPath() { } protected String getBaseURl() { - return "http://localhost:" + port + "/" + getContextPath(); + return "http://localhost:" + port + getContextPath(); } protected ResponseEntity get(final String path, final Class responseBodyClass) { diff --git a/store-implementation/accumulo-store/pom.xml b/store-implementation/accumulo-store/pom.xml index d8fbc21adf4..377ea31a5c1 100644 --- a/store-implementation/accumulo-store/pom.xml +++ b/store-implementation/accumulo-store/pom.xml @@ -25,23 +25,24 @@ accumulo-store + ${revision} uk.gov.gchq.gaffer graph - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer hdfs-library - ${project.parent.version} + ${project.version} uk.gov.gchq.gaffer sketches-library - ${project.parent.version} + ${project.version} @@ -104,69 +105,69 @@ uk.gov.gchq.gaffer store - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer data - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer graph - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer operation - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer common-util - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer integration-test - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer integration-test - ${project.parent.version} + ${project.version} test uk.gov.gchq.gaffer serialisation - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer hdfs-library - ${project.parent.version} + ${project.version} test-jar test uk.gov.gchq.gaffer map-store - ${project.parent.version} + ${project.version} test @@ -174,15 +175,10 @@ hadoop-hdfs test - - org.junit.platform - junit-platform-suite - test - org.mockito mockito-inline - ${mockito.version} + ${mockito-inline.version} test diff --git a/store-implementation/federated-store/pom.xml b/store-implementation/federated-store/pom.xml index 8da24f276b4..627ccfdb4c4 100644 --- a/store-implementation/federated-store/pom.xml +++ b/store-implementation/federated-store/pom.xml @@ -157,6 +157,12 @@ test-jar test + + uk.gov.gchq.gaffer + hdfs-library + ${project.parent.version} + test + org.apache.hadoop hadoop-hdfs diff --git a/store-implementation/map-store/pom.xml b/store-implementation/map-store/pom.xml index f0e7a67f485..975784988fb 100755 --- a/store-implementation/map-store/pom.xml +++ b/store-implementation/map-store/pom.xml @@ -108,10 +108,5 @@ ${project.parent.version} test - - org.junit.platform - junit-platform-suite - test -