diff --git a/NOTICES b/NOTICES index 891b105db..e2972929f 100755 --- a/NOTICES +++ b/NOTICES @@ -20,7 +20,7 @@ Gaffer tools is built using maven. This process will automatically pull in depen projects below. -Gaffer (uk.gov.gchq.gaffer:gaffer2:2.0.0-alpha-0.2): +Gaffer (uk.gov.gchq.gaffer:gaffer2:2.0.0-alpha-0.3): - Apache License, Version 2.0 diff --git a/mini-accumulo-cluster/pom.xml b/mini-accumulo-cluster/pom.xml index fc96026c2..2f93f97bc 100755 --- a/mini-accumulo-cluster/pom.xml +++ b/mini-accumulo-cluster/pom.xml @@ -84,6 +84,22 @@ + + org.apache.accumulo + accumulo-shell + ${accumulo.version} + + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + diff --git a/mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java b/mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java index 3b63e23ec..85e046111 100644 --- a/mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java +++ b/mini-accumulo-cluster/src/test/java/uk/gov/gchq/gaffer/miniaccumulocluster/MiniAccumuloClusterControllerTest.java @@ -16,13 +16,11 @@ package uk.gov.gchq.gaffer.miniaccumulocluster; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class MiniAccumuloClusterControllerTest { @Test @@ -58,9 +56,9 @@ public void shouldStartAndStopCluster() throws Exception { Thread.sleep(5000); // Then - assertNull(null != accumuloException[0] ? accumuloException[0].getMessage() : "", accumuloException[0]); - assertTrue("store.properties was not generated", new File(miniAccumuloClusterName + "/store.properties").exists()); - assertEquals(1024, runner[0].getHeapSize()); + assertThat(accumuloException[0]).withFailMessage(null != accumuloException[0] ? accumuloException[0].getMessage() : "").isNull(); + assertThat(new File(miniAccumuloClusterName + "/store.properties").exists()).withFailMessage("store.properties was not generated").isTrue(); + assertThat(1024).isEqualTo(runner[0].getHeapSize()); } finally { if (null != runner[0]) { runner[0].stop(); diff --git a/performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java b/performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java index ac827f46b..0a22bbf87 100644 --- a/performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java +++ b/performance-testing/performance-testing-accumulo-store/src/test/java/uk/gov/gchq/gaffer/accumulostore/performancetesting/ingest/TestAccumuloStoreRandomElementIngestTest.java @@ -16,14 +16,12 @@ package uk.gov.gchq.gaffer.accumulostore.performancetesting.ingest; import org.apache.hadoop.conf.Configuration; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import uk.gov.gchq.gaffer.accumulostore.AccumuloProperties; import uk.gov.gchq.gaffer.accumulostore.AccumuloStore; import uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore; -import uk.gov.gchq.gaffer.commonutil.CommonTestConstants; import uk.gov.gchq.gaffer.commonutil.StreamUtil; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; @@ -33,12 +31,13 @@ import uk.gov.gchq.gaffer.store.StoreException; import uk.gov.gchq.gaffer.store.schema.Schema; +import java.io.File; import java.io.IOException; public class TestAccumuloStoreRandomElementIngestTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(CommonTestConstants.TMP_DIRECTORY); + @TempDir + public File tempFolder; @Test public void testAccumuloStoreRandomElementIngestTestRuns() throws StoreException, OperationException, IOException { @@ -49,7 +48,7 @@ public void testAccumuloStoreRandomElementIngestTestRuns() throws StoreException testProperties.setElementSupplierClass(RmatElementSupplier.class.getName()); testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); testProperties.setRmatMaxNodeId(100L); - testProperties.setTempDirectory(tempFolder.newFolder().getCanonicalPath()); + testProperties.setTempDirectory(tempFolder.getCanonicalPath()); final Schema schema = Schema.fromJson(StreamUtil.schemas(Constants.class)); final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( diff --git a/performance-testing/performance-testing-aws/pom.xml b/performance-testing/performance-testing-aws/pom.xml index e318f170b..2bc959f2c 100644 --- a/performance-testing/performance-testing-aws/pom.xml +++ b/performance-testing/performance-testing-aws/pom.xml @@ -60,6 +60,22 @@ httpcore 4.4.4 + + org.apache.accumulo + accumulo-core + ${accumulo.version} + + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + diff --git a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java b/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java index 8c6b802aa..b9151077b 100644 --- a/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java +++ b/performance-testing/performance-testing-aws/src/main/java/uk/gov/gchq/gaffer/performancetesting/aws/PublishAccumuloMetricsToCloudWatch.java @@ -24,17 +24,19 @@ import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; import com.amazonaws.services.cloudwatch.model.PutMetricDataResult; import com.amazonaws.services.cloudwatch.model.StandardUnit; -import org.apache.accumulo.core.client.ZooKeeperInstance; -import org.apache.accumulo.core.client.impl.MasterClient; -import org.apache.accumulo.core.client.impl.Tables; +import org.apache.accumulo.core.client.Accumulo; +import org.apache.accumulo.core.client.AccumuloClient; +import org.apache.accumulo.core.clientImpl.MasterClient; +import org.apache.accumulo.core.clientImpl.Tables; +import org.apache.accumulo.core.conf.SiteConfiguration; +import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.master.thrift.MasterClientService; import org.apache.accumulo.core.master.thrift.MasterMonitorInfo; import org.apache.accumulo.core.master.thrift.TableInfo; import org.apache.accumulo.core.master.thrift.TabletServerStatus; -import org.apache.accumulo.core.trace.Tracer; +import org.apache.accumulo.core.trace.TraceUtil; import org.apache.accumulo.core.util.Pair; -import org.apache.accumulo.server.AccumuloServerContext; -import org.apache.accumulo.server.conf.ServerConfigurationFactory; +import org.apache.accumulo.server.ServerContext; import org.apache.thrift.TException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,12 +58,12 @@ public class PublishAccumuloMetricsToCloudWatch implements Runnable { private final String zookeepers; private int interval = 60; - private ZooKeeperInstance instance; - private AccumuloServerContext context; + private AccumuloClient instance; + private ServerContext context; private MasterClientService.Client client; private AmazonCloudWatch cloudwatch; - private Map tableIdToNameMap; + private Map tableIdToNameMap; private Date previousCaptureDate = null; private Map>, Double> previousMetrics = null; @@ -77,9 +79,8 @@ public PublishAccumuloMetricsToCloudWatch(final String instanceName, final Strin private void connect() { // Connect to Accumulo Master - this.instance = new ZooKeeperInstance(this.instanceName, this.zookeepers); - ServerConfigurationFactory config = new ServerConfigurationFactory(this.instance); - this.context = new AccumuloServerContext(config); + this.instance = Accumulo.newClient().to(instanceName, zookeepers).as("admin", "admin").build(); + this.context = new ServerContext(new SiteConfiguration()); this.client = MasterClient.getConnection(this.context); // Set up connection to AWS CloudWatch @@ -96,7 +97,7 @@ private void disconnect() { private String getTableNameForId(final String id) { if (this.tableIdToNameMap == null || !this.tableIdToNameMap.containsKey(id)) { // Refresh the cache as a table may have just been created - this.tableIdToNameMap = Tables.getIdToNameMap(this.instance); + this.tableIdToNameMap = Tables.getIdToNameMap(this.context); } return this.tableIdToNameMap.get(id); @@ -106,7 +107,7 @@ private String getTableNameForId(final String id) { private List gatherMetrics() throws TException { final String awsEmrJobFlowId = AwsEmrUtils.getJobFlowId(); - final MasterMonitorInfo stats = this.client.getMasterStats(Tracer.traceInfo(), this.context.rpcCreds()); + final MasterMonitorInfo stats = this.client.getMasterStats(TraceUtil.traceInfo(), this.context.rpcCreds()); LOGGER.trace(stats.toString()); final Date now = new Date(); diff --git a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java b/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java index 2603c6795..1847abed1 100644 --- a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java +++ b/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestElementIngestTest.java @@ -16,13 +16,11 @@ package uk.gov.gchq.gaffer.performancetesting.ingest; import org.apache.commons.io.FileUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import uk.gov.gchq.gaffer.accumulostore.AccumuloProperties; import uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore; -import uk.gov.gchq.gaffer.commonutil.CommonTestConstants; import uk.gov.gchq.gaffer.commonutil.StreamUtil; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; @@ -34,12 +32,12 @@ import java.io.IOException; import java.util.List; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class TestElementIngestTest { - @Rule - public TemporaryFolder folder = new TemporaryFolder(CommonTestConstants.TMP_DIRECTORY); + @TempDir + public File folder; @Test public void testElementIngestTestRuns() { @@ -65,7 +63,7 @@ public void testElementIngestTestRuns() { final double result = test.run(); // Then - assertTrue(result > 0.0D); + assertThat(result > 0.0D).isTrue(); } @Test @@ -78,7 +76,7 @@ public void testElementIngestTestOutputsToListener() throws IOException { testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); testProperties.setRmatMaxNodeId(100L); testProperties.setMetricsListenerClass(FileWriterMetricsListener.class.getName()); - final File metricsResults = folder.newFile(); + final File metricsResults = new File(folder, "metricsResults.txt"); final String metricsResultsFilename = metricsResults.getPath(); testProperties.setProperty(FileWriterMetricsListener.FILENAME, metricsResultsFilename); final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( @@ -97,15 +95,15 @@ public void testElementIngestTestOutputsToListener() throws IOException { final List lines = FileUtils.readLines(new File(metricsResultsFilename)); // Then - assertTrue(lines.size() > 0); + assertThat(lines.size() > 0).isTrue(); final int offsetBatch = IngestMetrics.ELEMENTS_PER_SECOND_BATCH.length() + 1; final int offsetOverall = IngestMetrics.ELEMENTS_PER_SECOND_OVERALL.length() + 1; for (int i = 0; i < lines.size() - 2; i++) { final String[] tokens = lines.get(i).split(","); - assertTrue(tokens[0].replaceAll(" ", "").startsWith(IngestMetrics.ELEMENTS_PER_SECOND_BATCH + ":")); - assertTrue(nullOrPositive(tokens[0].substring(offsetBatch))); - assertTrue(tokens[1].replaceAll(" ", "").startsWith(IngestMetrics.ELEMENTS_PER_SECOND_OVERALL + ":")); - assertTrue(nullOrPositive(tokens[1].substring(offsetOverall))); + assertThat(tokens[0].replaceAll(" ", "").startsWith(IngestMetrics.ELEMENTS_PER_SECOND_BATCH + ":")).isTrue(); + assertThat(nullOrPositive(tokens[0].substring(offsetBatch))).isTrue(); + assertThat(tokens[1].replaceAll(" ", "").startsWith(IngestMetrics.ELEMENTS_PER_SECOND_OVERALL + ":")).isTrue(); + assertThat(nullOrPositive(tokens[1].substring(offsetOverall))).isTrue(); } } diff --git a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java b/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java index c2ee7cd5a..937e927cc 100644 --- a/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java +++ b/performance-testing/performance-testing-core/src/test/java/uk/gov/gchq/gaffer/performancetesting/ingest/TestQueryTest.java @@ -16,13 +16,11 @@ package uk.gov.gchq.gaffer.performancetesting.ingest; import org.apache.commons.io.FileUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import uk.gov.gchq.gaffer.accumulostore.AccumuloProperties; import uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore; -import uk.gov.gchq.gaffer.commonutil.CommonTestConstants; import uk.gov.gchq.gaffer.commonutil.StreamUtil; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; @@ -43,12 +41,12 @@ import java.util.List; import java.util.stream.Stream; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class TestQueryTest { - @Rule - public TemporaryFolder folder = new TemporaryFolder(CommonTestConstants.TMP_DIRECTORY); + @TempDir + public File folder; @Test public void testQueryTestRuns() throws OperationException { @@ -79,7 +77,7 @@ public void testQueryTestRuns() throws OperationException { final double result = test.run(); // Then - assertTrue(result > 0.0D); + assertThat(result > 0.0D).isTrue(); } @Test @@ -92,7 +90,7 @@ public void testQueryTestOutputsToListener() throws IOException, OperationExcept testProperties.setRmatProbabilities(Constants.RMAT_PROBABILITIES); testProperties.setRmatMaxNodeId(100L); testProperties.setMetricsListenerClass(FileWriterMetricsListener.class.getName()); - final File metricsResults = folder.newFile(); + final File metricsResults = new File(folder, "metricsResults.txt"); final String metricsResultsFilename = metricsResults.getPath(); testProperties.setProperty(FileWriterMetricsListener.FILENAME, metricsResultsFilename); final AccumuloProperties storeProperties = AccumuloProperties.loadStoreProperties( @@ -116,13 +114,13 @@ public void testQueryTestOutputsToListener() throws IOException, OperationExcept final List lines = FileUtils.readLines(new File(metricsResultsFilename)); // Then - assertTrue(lines.size() > 0); + assertThat(lines.size() > 0).isTrue(); lines.forEach(line -> { final String[] fields = line.split(", "); - assertTrue(fields[0].startsWith(QueryMetrics.RESULTS_PER_SECOND)); - assertTrue(Double.parseDouble(fields[0].split(":")[1]) > 0.0D); - assertTrue(fields[1].startsWith(QueryMetrics.SEEDS_PER_SECOND)); - assertTrue(Double.parseDouble(fields[1].split(":")[1]) > 0.0D); + assertThat(fields[0].startsWith(QueryMetrics.RESULTS_PER_SECOND)).isTrue(); + assertThat(Double.parseDouble(fields[0].split(":")[1]) > 0.0D).isTrue(); + assertThat(fields[1].startsWith(QueryMetrics.SEEDS_PER_SECOND)).isTrue(); + assertThat(Double.parseDouble(fields[1].split(":")[1]) > 0.0D).isTrue(); }); } } diff --git a/pom.xml b/pom.xml index f43e4cb2f..1a164e2bb 100755 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ uk.gov.gchq.gaffer gaffer2 - 2.0.0-alpha-0.2 + 2.0.0-alpha-0.3 gaffer-tools @@ -36,7 +36,7 @@ - 2.0.0-alpha-0.2 + 2.0.0-alpha-0.3 https://github.com/gchq/gaffer-tools diff --git a/python-shell/src/__init__.py b/python-shell/src/__init__.py index e69de29bb..3863129c1 100644 --- a/python-shell/src/__init__.py +++ b/python-shell/src/__init__.py @@ -0,0 +1,11 @@ +__version__ = "2.0.0-alpha-0.3" + +__title__ = "gafferpy" +__description__ = "Gaffer Python Shell" +__uri__ = "https://github.com/gchq/gafferpy-tools" +__doc__ = __description__ + " <" + __uri__ + ">" + +__author__ = "GCHQ" + +__license__ = "Apache 2.0" +__copyright__ = "Crown Copyright (c) 2016-2017" diff --git a/python-shell/src/examples/__init__.py b/python-shell/src/examples/__init__.py index 121d3a323..3863129c1 100644 --- a/python-shell/src/examples/__init__.py +++ b/python-shell/src/examples/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.0.0-alpha-0.2" +__version__ = "2.0.0-alpha-0.3" __title__ = "gafferpy" __description__ = "Gaffer Python Shell" diff --git a/python-shell/src/gafferpy/__init__.py b/python-shell/src/gafferpy/__init__.py index 121d3a323..3863129c1 100644 --- a/python-shell/src/gafferpy/__init__.py +++ b/python-shell/src/gafferpy/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.0.0-alpha-0.2" +__version__ = "2.0.0-alpha-0.3" __title__ = "gafferpy" __description__ = "Gaffer Python Shell" diff --git a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java b/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java index cf429e1ca..10fd0dce6 100644 --- a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java +++ b/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestPreferentialAttachmentCache.java @@ -15,7 +15,7 @@ */ package uk.gov.gchq.gaffer.randomelementgeneration.cache; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.HashMap; @@ -25,8 +25,7 @@ import java.util.Set; import java.util.stream.IntStream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class TestPreferentialAttachmentCache { @@ -43,7 +42,7 @@ public void testGetReturnsOneOfTheElementsAdded() { IntStream.range(0, 100).forEach(i -> results.add(cache.get())); // Then - results.forEach(i -> assertTrue(data.contains(i))); + results.forEach(i -> assertThat(data.contains(i)).isTrue()); } @Test @@ -56,7 +55,7 @@ public void testMaxSizeIsRespected() { final long numberOfElements = cache.getNumberOfElements(); // Then - assertEquals(10, numberOfElements); + assertThat(numberOfElements).isEqualTo(10); } /** @@ -83,6 +82,6 @@ public void testPowerLaw() { final long minFrequency = itemToCount.values().stream().mapToLong(Long::longValue).min().getAsLong(); // Then - assertTrue(maxFrequency / minFrequency > 5); + assertThat(maxFrequency / minFrequency > 5).isTrue(); } } diff --git a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java b/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java index a97d9b19c..3777da4a4 100644 --- a/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java +++ b/random-element-generation/src/test/java/uk/gov/gchq/gaffer/randomelementgeneration/cache/TestProbabilityGenerator.java @@ -15,7 +15,7 @@ */ package uk.gov.gchq.gaffer.randomelementgeneration.cache; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Map; import java.util.SortedMap; @@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.IntStream; -import static junit.framework.TestCase.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class TestProbabilityGenerator { @@ -46,7 +46,7 @@ public void testWhenUniform() { // Then final double ratio = ((double) counts.get("A")) / counts.get("B"); - assertTrue(0.99D < ratio && ratio < 1.01D); + assertThat(0.99D < ratio && ratio < 1.01D).isTrue(); } @Test @@ -68,6 +68,6 @@ public void testWhenUnbalanced() { // Then final double ratio = ((double) counts.get("A")) / counts.get("B"); - assertTrue(ratio > 100.0D); + assertThat(ratio > 100.0D).isTrue(); } } diff --git a/ui/pom.xml b/ui/pom.xml index 7fcd27d1f..92bc8aa93 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -43,10 +43,15 @@ com.google.guava guava - - 25.0-jre + + [25.0-jre,) test + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey.version} + uk.gov.gchq.gaffer proxy-store diff --git a/ui/src/test/java/uk/gov/gchq/gaffer/ui/QueryBuilderST.java b/ui/src/test/java/uk/gov/gchq/gaffer/ui/QueryBuilderST.java index d748c3ada..fc71984cf 100644 --- a/ui/src/test/java/uk/gov/gchq/gaffer/ui/QueryBuilderST.java +++ b/ui/src/test/java/uk/gov/gchq/gaffer/ui/QueryBuilderST.java @@ -18,10 +18,10 @@ package uk.gov.gchq.gaffer.ui; import com.google.common.collect.Maps; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; import org.openqa.selenium.Keys; @@ -45,9 +45,7 @@ import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; /** * UI system test. Runs a simple query for road use around junction M5:10. @@ -122,9 +120,9 @@ public class QueryBuilderST { private static String url; private static int slowFactor; - @BeforeClass + @BeforeAll public static void beforeClass() throws OperationException { - assertNotNull("System property " + GECKO_PROPERTY + " has not been set", System.getProperty(GECKO_PROPERTY)); + assertThat(System.getProperty(GECKO_PROPERTY)).withFailMessage("System property %s has not been set", GECKO_PROPERTY).isNotNull(); url = System.getProperty(URL_PROPERTY, DEFAULT_URL); slowFactor = Integer.parseInt(System.getProperty(SLOW_FACTOR_PROPERTY, DEFAULT_SLOW_FACTOR)); @@ -141,7 +139,7 @@ public static void beforeClass() throws OperationException { addNamedOperation(); } - @AfterClass + @AfterAll public static void afterClass() { try { driver.close(); @@ -151,7 +149,7 @@ public static void afterClass() { } } - @Before + @BeforeEach public void before() throws InterruptedException { driver.get(url); Thread.sleep(slowFactor * 1000); @@ -172,13 +170,14 @@ public void shouldFindRoadUseAroundJunctionM5_10() throws InterruptedException { click("execute-chain"); click("open-raw"); - assertEquals(EXPECTED_OPERATION_JSON, getElement("operation-0-json").getText().trim()); + assertThat(getElement("operation-0-json").getText().trim()).isEqualTo(EXPECTED_OPERATION_JSON); clickTab("Results"); final String results = getElement("raw-edge-results").getText().trim(); for (final String expectedResult : EXPECTED_RESULTS) { - assertTrue("Results did not contain: \n" + expectedResult - + "\nActual results: \n" + results, results.contains(expectedResult)); + assertThat(results.contains(expectedResult)) + .withFailMessage("Results did not contain: \n %s\nActual results: \n %s", expectedResult, results) + .isTrue(); } } @@ -196,7 +195,7 @@ public void shouldNotThrowErrorIfPageIsReloadedWithCustomView() throws Interrupt String result = getElement("raw-entity-results").getText().trim(); JSONSerialiser json = JSONSerialiser.getInstance(); List results = json.deserialise(result, List.class); - assertEquals(1, results.size()); + assertThat(results.size()).isEqualTo(1); } @Test @@ -212,8 +211,9 @@ public void shouldFindRoadUseAroundJunctionM5_10WithDatePicker() throws Interrup clickTab("Results"); final String results = getElement("raw-edge-results").getText().trim(); for (final String expectedResult : EXPECTED_RESULTS) { - assertTrue("Results did not contain: \n" + expectedResult - + "\nActual results: \n" + results, results.contains(expectedResult)); + assertThat(results.contains(expectedResult)) + .withFailMessage("Results did not contain: \n %s\nActual results: \n %s", expectedResult, results) + .isTrue(); } } @@ -252,7 +252,7 @@ public void shouldBeAbleToDeleteFiltersOnceCreated() throws InterruptedException " ]\n"; - assert (getElement("operation-0-json").getText().trim().contains(expectedString)); + assertThat(getElement("operation-0-json").getText().trim().contains(expectedString)).isTrue(); } @@ -270,7 +270,7 @@ public void shouldBeAbleToRunParameterisedQueries() throws InterruptedException, final String results = getElement("raw-other-results").getText().trim(); final List resultList = JSONSerialiser.deserialise(results.getBytes(), ArrayList.class); - assertEquals(2, resultList.size()); + assertThat(resultList.size()).isEqualTo(2); } @Test @@ -292,7 +292,7 @@ public void shouldBeAbleToSaveOperationChain() throws InterruptedException { click("md-confirm-button"); autoComplete("operation-name", "A Test Nam"); String text = getElement("operation-name").getAttribute("value"); - assertEquals("A Test Name", text); + assertThat(text).isEqualTo("A Test Name"); } private void enterText(final String id, final String value) throws InterruptedException { @@ -341,7 +341,7 @@ private void selectMultiOption(final String id, final String... values) throws I choice.click(); } - assertNotNull("You must provide at least one option", choice); + assertThat(choice).withFailMessage("You must provide at least one option").isNotNull(); choice.sendKeys(Keys.ESCAPE);