From 8a8311a24c169e50e09a4c936e3debc1fc205ef9 Mon Sep 17 00:00:00 2001 From: MishaDemianenko Date: Mon, 11 Jun 2018 16:27:49 +0200 Subject: [PATCH] Fix smashed imports --- ...chedulerShouldReportFailureWhenBusyIT.java | 30 +-- .../v1/runtime/integration/BoltConfigIT.java | 8 +- .../integration/BoltConnectionAuthIT.java | 19 +- .../runtime/integration/BoltConnectionIT.java | 27 ++- .../v1/runtime/integration/TransactionIT.java | 42 ++-- .../integration/AuthenticationIT.java | 23 +- .../BoltChannelAutoReadLimiterIT.java | 19 +- .../BoltThrottleMaxDurationIT.java | 20 +- .../RequiredTransportEncryptionIT.java | 5 +- .../integration/TransportErrorIT.java | 19 +- .../integration/TransportSessionIT.java | 113 ++++----- .../UnsupportedStructTypesV1IT.java | 11 +- .../UnsupportedStructTypesV1V2IT.java | 39 ++-- .../integration/BoltV2TransportIT.java | 39 ++-- .../UnsupportedStructTypesV2IT.java | 17 +- .../security/auth/AuthProceduresIT.java | 7 +- .../upgrade/StoreUpgradeOnStartupTest.java | 7 +- .../StoreUpgraderInterruptionTestIT.java | 7 +- ...onsistencyCheckServiceIntegrationTest.java | 15 +- .../AllNodesInStoreExistInLabelIndexTest.java | 10 +- .../checking/IndexConsistencyIT.java | 10 +- .../full/ExecutionOrderIntegrationTest.java | 7 +- .../full/FullCheckIntegrationTest.java | 25 +- .../javacompat/CypherLoggingTest.java | 2 +- .../javacompat/CypherUpdateMapTest.java | 10 +- .../internal/javacompat/EagerResultIT.java | 19 +- .../javacompat/ExecutionEngineTest.java | 8 +- .../javacompat/ExecutionResultTest.java | 6 +- .../NotificationAcceptanceTest.java | 3 +- .../SnapshotExecutionEngineTest.java | 30 +-- .../dbms/DatabaseImporterTest.java | 11 +- .../dbms/DiagnosticsReportCommandIT.java | 7 +- .../MemoryRecommendationsCommandTest.java | 100 ++++---- .../ImportToolNumericalFailureTest.java | 6 +- .../org/neo4j/tooling/ImportToolTest.java | 179 +++++++-------- .../impl/lucene/explicit/TestLuceneIndex.java | 5 +- .../impl/index/schema/RecoverIndexDropIT.java | 4 +- .../java/schema/DynamicIndexStoreViewIT.java | 5 +- .../MultipleIndexPopulationStressIT.java | 3 +- .../neo4j/test/ImpermanentGraphDatabase.java | 11 +- .../test/java/counts/RebuildCountsTest.java | 6 +- .../neo4j/graphdb/LabelsAcceptanceTest.java | 23 +- ...yTransactionsForConstraintCreatorTest.java | 4 +- ...ansactionsForConstraintDefinitionTest.java | 4 +- ...ansactionsForGraphDatabaseServiceTest.java | 4 +- ...datoryTransactionsForIndexCreatorTest.java | 4 +- ...oryTransactionsForIndexDefinitionTest.java | 4 +- ...TransactionsForIndexManagerFacadeTest.java | 4 +- .../MandatoryTransactionsForNodeTest.java | 4 +- ...datoryTransactionsForRelationshipTest.java | 4 +- .../MandatoryTransactionsForSchemaTest.java | 4 +- ...ForUniquenessConstraintDefinitionTest.java | 4 +- .../neo4j/graphdb/SchemaAcceptanceTest.java | 42 ++-- .../graphdb/schema/UpdateDeletedIndexIT.java | 2 +- .../java/org/neo4j/kernel/RecoveryIT.java | 8 +- .../org/neo4j/kernel/TestKernelExtension.java | 11 +- .../CompositeIndexAccessorCompatibility.java | 32 +-- .../CompositeIndexPopulatorCompatibility.java | 4 +- .../kernel/impl/api/SchemaLoggingIT.java | 2 +- ...nsactionRepresentationCommitProcessIT.java | 4 +- .../ControlledPopulationIndexProvider.java | 3 +- .../kernel/impl/api/index/IndexCRUDIT.java | 6 +- .../api/index/IndexPopulationJobTest.java | 8 +- .../impl/api/index/IndexRecoveryIT.java | 3 +- .../kernel/impl/api/index/IndexRestartIT.java | 15 +- .../impl/api/index/IndexStatisticsIT.java | 2 +- ...nessConstraintValidationConcurrencyIT.java | 4 +- .../state/NoChangeWriteTransactionTest.java | 6 +- .../neo4j/kernel/impl/core/NodeProxyTest.java | 6 +- .../impl/core/TestLoopRelationships.java | 42 ++-- .../kernel/impl/core/TestReadOnlyNeo4j.java | 3 +- .../kernel/impl/core/TestRelationship.java | 217 +++++++++--------- .../impl/core/TestRelationshipCount.java | 5 +- .../impl/core/TestShortStringProperties.java | 4 +- .../impl/event/TestTransactionEvents.java | 10 +- .../impl/recovery/KernelRecoveryTest.java | 6 +- ...ordStorageReaderRelTypesAndDegreeTest.java | 7 +- .../RelationshipChainPointerChasingTest.java | 15 +- .../store/RelationshipGroupStoreTest.java | 5 +- .../neo4j/metatest/TestGraphDescription.java | 3 +- .../batchinsert/internal/BatchInsertTest.java | 18 +- .../ParallelBatchImporterTest.java | 4 +- .../TestRecoveryMultipleDataSources.java | 3 +- .../java/recovery/UniquenessRecoveryTest.java | 3 +- 84 files changed, 778 insertions(+), 722 deletions(-) diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/runtime/integration/BoltSchedulerShouldReportFailureWhenBusyIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/runtime/integration/BoltSchedulerShouldReportFailureWhenBusyIT.java index d67b2a8d20643..dd2035f637e8b 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/runtime/integration/BoltSchedulerShouldReportFailureWhenBusyIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/runtime/integration/BoltSchedulerShouldReportFailureWhenBusyIT.java @@ -19,7 +19,6 @@ */ package org.neo4j.bolt.runtime.integration; -import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -35,12 +34,7 @@ import org.neo4j.bolt.AbstractBoltTransportsTest; import org.neo4j.bolt.runtime.BoltConnection; -import org.neo4j.bolt.v1.messaging.message.DiscardAllMessage; -import org.neo4j.bolt.v1.messaging.message.InitMessage; -import org.neo4j.bolt.v1.messaging.message.RunMessage; -import org.neo4j.bolt.v1.messaging.util.MessageMatchers; import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket; -import org.neo4j.bolt.v1.transport.integration.TransportTestUtil; import org.neo4j.bolt.v1.transport.socket.client.TransportConnection; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.kernel.api.exceptions.Status; @@ -54,8 +48,14 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.isA; import static org.hamcrest.CoreMatchers.startsWith; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.neo4j.bolt.v1.messaging.message.DiscardAllMessage.discardAll; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; +import static org.neo4j.bolt.v1.messaging.message.RunMessage.run; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgFailure; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; import static org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket.DEFAULT_CONNECTOR_KEY; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyReceives; @RunWith( Parameterized.class ) public class BoltSchedulerShouldReportFailureWhenBusyIT extends AbstractBoltTransportsTest @@ -119,8 +119,8 @@ public void shouldReportFailureWhenAllThreadsInThreadPoolAreBusy() throws Throwa { connection3 = connectAndPerformBoltHandshake( newConnection() ); - connection3.send( util.chunk( InitMessage.init( "TestClient/1.1", emptyMap() ) ) ); - MatcherAssert.assertThat( connection3, util.eventuallyReceives( + connection3.send( util.chunk( init( "TestClient/1.1", emptyMap() ) ) ); + assertThat( connection3, util.eventuallyReceives( msgFailure( Status.Request.NoThreadsAvailable, "There are no available threads to serve this request at the moment" ) ) ); userLogProvider.assertContainsMessageContaining( @@ -182,27 +182,27 @@ private void enterStreaming( TransportConnection connection, int sleepSeconds ) { connectAndPerformBoltHandshake( connection ); - connection.send( util.chunk( InitMessage.init( "TestClient/1.1", emptyMap() ) ) ); - MatcherAssert.assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) ); + connection.send( util.chunk( init( "TestClient/1.1", emptyMap() ) ) ); + assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); SECONDS.sleep( sleepSeconds ); // sleep a bit to allow worker thread return back to the pool - connection.send( util.chunk( RunMessage.run( "UNWIND RANGE (1, 100) AS x RETURN x" ) ) ); - MatcherAssert.assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) ); + connection.send( util.chunk( run( "UNWIND RANGE (1, 100) AS x RETURN x" ) ) ); + assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); } private TransportConnection connectAndPerformBoltHandshake( TransportConnection connection ) throws Exception { connection.connect( address ).send( util.acceptedVersions( 1, 0, 0, 0 ) ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); + assertThat( connection, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); return connection; } private void exitStreaming( TransportConnection connection ) throws Exception { - connection.send( util.chunk( DiscardAllMessage.discardAll() ) ); + connection.send( util.chunk( discardAll() ) ); - MatcherAssert.assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) ); + assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); } private void close( TransportConnection connection ) diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConfigIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConfigIT.java index fa078efccaeee..bf84d71e02134 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConfigIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConfigIT.java @@ -19,21 +19,21 @@ */ package org.neo4j.bolt.v1.runtime.integration; -import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; import org.neo4j.bolt.AbstractBoltTransportsTest; import org.neo4j.bolt.v1.messaging.message.InitMessage; import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket; -import org.neo4j.bolt.v1.transport.integration.TransportTestUtil; import org.neo4j.bolt.v1.transport.socket.client.TransportConnection; import org.neo4j.helpers.HostnamePort; import org.neo4j.kernel.configuration.BoltConnector; import org.neo4j.test.rule.SuppressOutput; import static java.util.Collections.emptyMap; +import static org.hamcrest.MatcherAssert.assertThat; import static org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket.DEFAULT_CONNECTOR_KEY; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects; import static org.neo4j.kernel.configuration.BoltConnector.EncryptionLevel.REQUIRED; public class BoltConfigIT extends AbstractBoltTransportsTest @@ -70,7 +70,7 @@ private void assertConnectionRejected( HostnamePort address, TransportConnection client.connect( address ) .send( util.defaultAcceptedVersions() ); - MatcherAssert.assertThat( client, TransportTestUtil.eventuallyDisconnects() ); + assertThat( client, eventuallyDisconnects() ); } private void assertConnectionAccepted( HostnamePort address, TransportConnection client ) throws Exception @@ -78,6 +78,6 @@ private void assertConnectionAccepted( HostnamePort address, TransportConnection client.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( InitMessage.init( "TestClient/1.1", emptyMap() ) ) ); - MatcherAssert.assertThat( client, util.eventuallyReceivesSelectedProtocolVersion() ); + assertThat( client, util.eventuallyReceivesSelectedProtocolVersion() ); } } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionAuthIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionAuthIT.java index 1eaba800e1c3f..e359829ee7793 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionAuthIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionAuthIT.java @@ -19,20 +19,21 @@ */ package org.neo4j.bolt.v1.runtime.integration; -import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; import org.neo4j.bolt.BoltChannel; -import org.neo4j.bolt.testing.BoltMatchers; import org.neo4j.bolt.testing.BoltResponseRecorder; import org.neo4j.bolt.v1.runtime.BoltStateMachine; import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.internal.Version; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.neo4j.bolt.testing.BoltMatchers.failedWithStatus; +import static org.neo4j.bolt.testing.BoltMatchers.succeeded; import static org.neo4j.bolt.testing.BoltMatchers.succeededWithMetadata; +import static org.neo4j.bolt.testing.BoltMatchers.verifyKillsConnection; import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.values.storable.Values.TRUE; import static org.neo4j.values.storable.Values.stringValue; @@ -62,8 +63,8 @@ public void shouldGiveCredentialsExpiredStatusOnExpiredCredentials() throws Thro machine.run( "CREATE ()", EMPTY_MAP, recorder ); // Then - MatcherAssert.assertThat( recorder.nextResponse(), succeededWithMetadata( "credentials_expired", TRUE ) ); - MatcherAssert.assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.CredentialsExpired ) ); + assertThat( recorder.nextResponse(), succeededWithMetadata( "credentials_expired", TRUE ) ); + assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.CredentialsExpired ) ); } @Test @@ -82,7 +83,7 @@ public void shouldGiveKernelVersionOnInit() throws Throwable machine.run( "CREATE ()", EMPTY_MAP, recorder ); // Then - MatcherAssert.assertThat( recorder.nextResponse(), succeededWithMetadata( "server", stringValue( version ) ) ); + assertThat( recorder.nextResponse(), succeededWithMetadata( "server", stringValue( version ) ) ); } @Test @@ -93,14 +94,14 @@ public void shouldCloseConnectionAfterAuthenticationFailure() throws Throwable // When... then BoltResponseRecorder recorder = new BoltResponseRecorder(); - BoltMatchers.verifyKillsConnection( () -> machine.init( USER_AGENT, map( + verifyKillsConnection( () -> machine.init( USER_AGENT, map( "scheme", "basic", "principal", "neo4j", "credentials", "j4oen" ), recorder ) ); // ...and - MatcherAssert.assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.Unauthorized ) ); + assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.Unauthorized ) ); } @Test @@ -119,7 +120,7 @@ public void shouldBeAbleToActOnSessionWhenUpdatingCredentials() throws Throwable machine.run( "CREATE ()", EMPTY_MAP, recorder ); // then - MatcherAssert.assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); - MatcherAssert.assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); } } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionIT.java index 1a2b62625db9b..17a33938b907c 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/BoltConnectionIT.java @@ -20,7 +20,6 @@ package org.neo4j.bolt.v1.runtime.integration; import org.hamcrest.CoreMatchers; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -29,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.neo4j.bolt.BoltChannel; -import org.neo4j.bolt.testing.BoltMatchers; import org.neo4j.bolt.testing.BoltResponseRecorder; import org.neo4j.bolt.testing.RecordedBoltResponse; import org.neo4j.bolt.v1.messaging.BoltResponseMessage; @@ -54,6 +52,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.neo4j.bolt.testing.BoltMatchers.failedWithStatus; +import static org.neo4j.bolt.testing.BoltMatchers.succeeded; import static org.neo4j.bolt.testing.BoltMatchers.verifyKillsConnection; import static org.neo4j.bolt.testing.NullResponseHandler.nullResponseHandler; import static org.neo4j.bolt.v1.messaging.BoltResponseMessage.IGNORED; @@ -152,7 +151,7 @@ public void shouldExecuteStatement() throws Throwable machine.run( "CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS, recorder ); // Then - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); // When recorder.reset(); @@ -179,7 +178,7 @@ public void shouldSucceedOn__run__pullAll__run() throws Throwable machine.run( "RETURN 1", EMPTY_PARAMS, recorder ); // Then - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); } @Test @@ -198,7 +197,7 @@ public void shouldSucceedOn__run__discardAll__run() throws Throwable machine.run( "RETURN 1", EMPTY_PARAMS, recorder ); // Then - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); } @Test @@ -214,17 +213,17 @@ public void shouldSucceedOn__run_BEGIN__pullAll__run_COMMIT__pullALL__run_COMMIT machine.pullAll( recorder ); machine.run( "COMMIT", EMPTY_PARAMS, recorder ); machine.pullAll( recorder ); - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); // When I run a new statement recorder.reset(); machine.run( "BEGIN", EMPTY_PARAMS, recorder ); // Then - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); } @Test @@ -334,7 +333,7 @@ public void shouldHandleImplicitCommitFailure() throws Throwable BoltResponseRecorder recorder = new BoltResponseRecorder(); machine.run( "MATCH (n:Victim) DELETE n", EMPTY_PARAMS, recorder ); // Then the statement running should have succeeded - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); recorder.reset(); machine.discardAll( recorder ); @@ -373,8 +372,8 @@ public void shouldAllowUserControlledRollbackOnExplicitTxFailure() throws Throwa machine.run( "ROLLBACK", EMPTY_PARAMS, recorder ); // Then both operations should succeed - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); + assertThat( recorder.nextResponse(), succeeded() ); } @Test @@ -637,7 +636,7 @@ private Record[] runAndPull( BoltStateMachine machine, String statement, MapValu machine.run( statement, params, nullResponseHandler() ); machine.pullAll( recorder ); RecordedBoltResponse response = recorder.nextResponse(); - Assert.assertEquals( expectedResponse, response.message() ); + assertEquals( expectedResponse, response.message() ); return response.records(); } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/TransactionIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/TransactionIT.java index 9667d43077708..0a97d3663a98b 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/TransactionIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/runtime/integration/TransactionIT.java @@ -23,8 +23,6 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.AbstractHandler; -import org.hamcrest.core.AllOf; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -35,7 +33,6 @@ import javax.servlet.http.HttpServletResponse; import org.neo4j.bolt.BoltChannel; -import org.neo4j.bolt.testing.BoltMatchers; import org.neo4j.bolt.testing.BoltResponseRecorder; import org.neo4j.bolt.v1.runtime.BoltConnectionFatality; import org.neo4j.bolt.v1.runtime.BoltStateMachine; @@ -53,11 +50,16 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.AllOf.allOf; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.mock; import static org.neo4j.bolt.testing.BoltMatchers.containsRecord; import static org.neo4j.bolt.testing.BoltMatchers.failedWithStatus; import static org.neo4j.bolt.testing.BoltMatchers.succeeded; +import static org.neo4j.bolt.testing.BoltMatchers.succeededWithMetadata; +import static org.neo4j.bolt.testing.BoltMatchers.succeededWithRecord; +import static org.neo4j.bolt.testing.BoltMatchers.wasIgnored; import static org.neo4j.bolt.testing.NullResponseHandler.nullResponseHandler; import static org.neo4j.values.virtual.VirtualValues.EMPTY_MAP; @@ -162,7 +164,7 @@ public void shouldReceiveBookmarkOnCommitAndDiscardAll() throws Throwable assertThat( recorder.nextResponse(), succeeded() ); assertThat( recorder.nextResponse(), succeeded() ); assertThat( recorder.nextResponse(), succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); + assertThat( recorder.nextResponse(), succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); } @Test @@ -189,7 +191,7 @@ public void shouldReceiveBookmarkOnCommitAndPullAll() throws Throwable assertThat( recorder.nextResponse(), succeeded() ); assertThat( recorder.nextResponse(), succeeded() ); assertThat( recorder.nextResponse(), succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); + assertThat( recorder.nextResponse(), succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); } @Test @@ -234,9 +236,9 @@ public void shouldReadYourOwnWrites() throws Exception machine.run( "COMMIT", EMPTY_MAP, nullResponseHandler() ); machine.pullAll( recorder ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( "two" ) ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); + assertThat( recorder.nextResponse(), succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); + assertThat( recorder.nextResponse(), succeededWithRecord( "two" ) ); + assertThat( recorder.nextResponse(), succeededWithMetadata( "bookmark", BOOKMARK_PATTERN ) ); } thread.join(); @@ -329,8 +331,8 @@ public void shouldInterpretEmptyStatementAsReuseLastStatementInAutocommitTransac machine.pullAll( recorder ); // Then - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 1L ) ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 1L ) ); + assertThat( recorder.nextResponse(), succeededWithRecord( 1L ) ); + assertThat( recorder.nextResponse(), succeededWithRecord( 1L ) ); } @Test @@ -352,8 +354,8 @@ public void shouldInterpretEmptyStatementAsReuseLastStatementInExplicitTransacti machine.discardAll( nullResponseHandler() ); // Then - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 1L ) ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 1L ) ); + assertThat( recorder.nextResponse(), succeededWithRecord( 1L ) ); + assertThat( recorder.nextResponse(), succeededWithRecord( 1L ) ); } @Test @@ -375,8 +377,8 @@ public void beginShouldNotOverwriteLastStatement() throws Throwable machine.discardAll( nullResponseHandler() ); // Then - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 1L ) ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 1L ) ); + assertThat( recorder.nextResponse(), succeededWithRecord( 1L ) ); + assertThat( recorder.nextResponse(), succeededWithRecord( 1L ) ); } @Test @@ -396,11 +398,11 @@ public void shouldCloseAutoCommitTransactionAndRespondToNextStatementWhenRunFail // Then assertThat( recorder.nextResponse(), failedWithStatus( Status.Statement.SyntaxError ) ); - assertThat( recorder.nextResponse(), BoltMatchers.wasIgnored() ); + assertThat( recorder.nextResponse(), wasIgnored() ); assertThat( recorder.nextResponse(), succeeded() ); assertThat( recorder.nextResponse(), succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 2L ) ); - Assert.assertEquals( recorder.responseCount(), 0 ); + assertThat( recorder.nextResponse(), succeededWithRecord( 2L ) ); + assertEquals( recorder.responseCount(), 0 ); } @Test @@ -420,11 +422,11 @@ public void shouldCloseAutoCommitTransactionAndRespondToNextStatementWhenStreami // Then assertThat( recorder.nextResponse(), succeeded() ); - assertThat( recorder.nextResponse(), AllOf.allOf( containsRecord( 1L ), failedWithStatus( Status.Statement.ArithmeticError ) ) ); + assertThat( recorder.nextResponse(), allOf( containsRecord( 1L ), failedWithStatus( Status.Statement.ArithmeticError ) ) ); assertThat( recorder.nextResponse(), succeeded() ); assertThat( recorder.nextResponse(), succeeded() ); - assertThat( recorder.nextResponse(), BoltMatchers.succeededWithRecord( 2L ) ); - Assert.assertEquals( recorder.responseCount(), 0 ); + assertThat( recorder.nextResponse(), succeededWithRecord( 2L ) ); + assertEquals( recorder.responseCount(), 0 ); } public static Server createHttpServer( diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java index 2eaabae10989e..55da6d93eeaca 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/AuthenticationIT.java @@ -44,7 +44,6 @@ import org.neo4j.bolt.v1.messaging.message.ResetMessage; import org.neo4j.bolt.v1.messaging.message.ResponseMessage; import org.neo4j.bolt.v1.messaging.message.RunMessage; -import org.neo4j.bolt.v1.messaging.util.MessageMatchers; import org.neo4j.bolt.v1.transport.socket.client.TransportConnection; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.helpers.HostnamePort; @@ -65,7 +64,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgFailure; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgIgnored; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects; import static org.neo4j.helpers.collection.MapUtil.map; public class AuthenticationIT extends AbstractBoltTransportsTest @@ -134,7 +135,7 @@ public void shouldFailIfWrongCredentials() throws Throwable assertThat( connection, util.eventuallyReceives( msgFailure( Status.Security.Unauthorized, "The client is unauthorized due to authentication failure." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -175,7 +176,7 @@ public void shouldFailIfWrongCredentialsFollowingSuccessfulLogin() throws Throwa assertThat( connection, util.eventuallyReceives( msgFailure( Status.Security.Unauthorized, "The client is unauthorized due to authentication failure." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -195,7 +196,7 @@ public void shouldFailIfMalformedAuthTokenWrongType() throws Throwable "Unsupported authentication token, the value associated with the key `principal` " + "must be a String but was: ArrayList" ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -214,7 +215,7 @@ public void shouldFailIfMalformedAuthTokenMissingKey() throws Throwable assertThat( connection, util.eventuallyReceives( msgFailure( Status.Security.Unauthorized, "Unsupported authentication token, missing key `credentials`" ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -232,7 +233,7 @@ public void shouldFailIfMalformedAuthTokenMissingScheme() throws Throwable assertThat( connection, util.eventuallyReceives( msgFailure( Status.Security.Unauthorized, "Unsupported authentication token, missing key `scheme`" ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -251,7 +252,7 @@ public void shouldFailIfMalformedAuthTokenUnknownScheme() throws Throwable assertThat( connection, util.eventuallyReceives( msgFailure( Status.Security.Unauthorized, "Unsupported authentication token, scheme 'unknown' is not supported." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -474,7 +475,7 @@ public void shouldFailWhenReusingTheSamePassword() throws Throwable AckFailureMessage.ackFailure(), RunMessage.run( "CALL dbms.security.changePassword", singletonMap( "password", "abc" ) ), PullAllMessage.pullAll() ) ); - assertThat( connection, util.eventuallyReceives( MessageMatchers.msgIgnored(), msgSuccess(), msgSuccess(), msgSuccess() ) ); + assertThat( connection, util.eventuallyReceives( msgIgnored(), msgSuccess(), msgSuccess(), msgSuccess() ) ); } @Test @@ -505,7 +506,7 @@ public void shouldFailWhenSubmittingEmptyPassword() throws Throwable AckFailureMessage.ackFailure(), RunMessage.run( "CALL dbms.security.changePassword", singletonMap( "password", "abc" ) ), PullAllMessage.pullAll() ) ); - assertThat( connection, util.eventuallyReceives( MessageMatchers.msgIgnored(), msgSuccess(), msgSuccess(), msgSuccess() ) ); + assertThat( connection, util.eventuallyReceives( msgIgnored(), msgSuccess(), msgSuccess(), msgSuccess() ) ); } @Test @@ -531,7 +532,7 @@ public void shouldNotBeAbleToReadWhenPasswordChangeRequired() throws Throwable assertThat( connection, util.eventuallyReceives( msgFailure( Status.Security.CredentialsExpired, "The credentials you provided were valid, but must be changed before you can use this instance." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } class FailureMsgMatcher extends TypeSafeMatcher @@ -583,7 +584,7 @@ private FailureMessage collectAuthFailureOnFailedAuth() assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); assertThat( connection, util.eventuallyReceives( failureRecorder ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } catch ( Exception ex ) { diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltChannelAutoReadLimiterIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltChannelAutoReadLimiterIT.java index 0047643594320..67c7ea1af624b 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltChannelAutoReadLimiterIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltChannelAutoReadLimiterIT.java @@ -30,10 +30,6 @@ import org.neo4j.bolt.runtime.BoltConnectionReadLimiter; import org.neo4j.bolt.v1.messaging.Neo4jPackV1; -import org.neo4j.bolt.v1.messaging.message.DiscardAllMessage; -import org.neo4j.bolt.v1.messaging.message.InitMessage; -import org.neo4j.bolt.v1.messaging.message.RunMessage; -import org.neo4j.bolt.v1.messaging.util.MessageMatchers; import org.neo4j.bolt.v1.transport.socket.client.SocketConnection; import org.neo4j.bolt.v1.transport.socket.client.TransportConnection; import org.neo4j.collection.RawIterator; @@ -59,6 +55,10 @@ import static org.hamcrest.CoreMatchers.anything; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; +import static org.neo4j.bolt.v1.messaging.message.DiscardAllMessage.discardAll; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; +import static org.neo4j.bolt.v1.messaging.message.RunMessage.run; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; import static org.neo4j.internal.kernel.api.procs.ProcedureSignature.procedureSignature; public class BoltChannelAutoReadLimiterIT @@ -110,24 +110,23 @@ public void largeNumberOfSlowRunningJobsShouldChangeAutoReadState() throws Excep connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ) ) ); + init( "TestClient/1.1", emptyMap() ) ) ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) ); + assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); // when for ( int i = 0; i < numberOfRunDiscardPairs; i++ ) { connection.send( util.chunk( - RunMessage.run( "CALL boltissue.sleep( $data )", ValueUtils.asMapValue( singletonMap( "data", largeString ) ) ), - DiscardAllMessage.discardAll() - ) ); + run( "CALL boltissue.sleep( $data )", ValueUtils.asMapValue( singletonMap( "data", largeString ) ) ), + discardAll() ) ); } // expect for ( int i = 0; i < numberOfRunDiscardPairs; i++ ) { - assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess(), MessageMatchers.msgSuccess() ) ); + assertThat( connection, util.eventuallyReceives( msgSuccess(), msgSuccess() ) ); } logProvider.assertAtLeastOnce( diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltThrottleMaxDurationIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltThrottleMaxDurationIT.java index 0b10ba3fd0286..bf21f6265786f 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltThrottleMaxDurationIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/BoltThrottleMaxDurationIT.java @@ -20,7 +20,6 @@ package org.neo4j.bolt.v1.transport.integration; import org.apache.commons.lang3.StringUtils; -import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.After; import org.junit.Before; @@ -40,9 +39,6 @@ import org.neo4j.bolt.runtime.BoltConnection; import org.neo4j.bolt.v1.messaging.Neo4jPackV1; -import org.neo4j.bolt.v1.messaging.message.InitMessage; -import org.neo4j.bolt.v1.messaging.message.RunMessage; -import org.neo4j.bolt.v1.messaging.util.MessageMatchers; import org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection; import org.neo4j.bolt.v1.transport.socket.client.SocketConnection; import org.neo4j.bolt.v1.transport.socket.client.TransportConnection; @@ -53,7 +49,6 @@ import org.neo4j.kernel.impl.util.ValueUtils; import org.neo4j.logging.AssertableLogProvider; import org.neo4j.test.TestGraphDatabaseFactory; -import org.neo4j.test.matchers.CommonMatchers; import org.neo4j.test.rule.concurrent.OtherThreadRule; import org.neo4j.test.rule.fs.EphemeralFileSystemRule; @@ -64,7 +59,12 @@ import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; import static org.neo4j.bolt.v1.messaging.message.PullAllMessage.pullAll; +import static org.neo4j.bolt.v1.messaging.message.RunMessage.run; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyReceives; +import static org.neo4j.test.matchers.CommonMatchers.matchesExceptionMessage; @RunWith( Parameterized.class ) public class BoltThrottleMaxDurationIT @@ -137,17 +137,17 @@ public void sendingButNotReceivingClientShouldBeKilledWhenWriteThrottleMaxDurati client.connect( address ) .send( util.acceptedVersions( 1, 0, 0, 0 ) ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ) ) ); + init( "TestClient/1.1", emptyMap() ) ) ); - MatcherAssert.assertThat( client, TransportTestUtil.eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); - MatcherAssert.assertThat( client, util.eventuallyReceives( MessageMatchers.msgSuccess() ) ); + assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); + assertThat( client, util.eventuallyReceives( msgSuccess() ) ); Future sender = otherThread.execute( state -> { for ( int i = 0; i < numberOfRunDiscardPairs; i++ ) { client.send( util.chunk( - RunMessage.run( "RETURN $data as data", ValueUtils.asMapValue( singletonMap( "data", largeString ) ) ), + run( "RETURN $data as data", ValueUtils.asMapValue( singletonMap( "data", largeString ) ) ), pullAll() ) ); } @@ -168,7 +168,7 @@ public void sendingButNotReceivingClientShouldBeKilledWhenWriteThrottleMaxDurati logProvider.assertAtLeastOnce( AssertableLogProvider.inLog( Matchers.containsString( BoltConnection.class.getPackage().getName() ) ).error( startsWith( "Unexpected error detected in bolt session" ), - CommonMatchers.matchesExceptionMessage( containsString( "will be closed because the client did not consume outgoing buffers for " ) ) ) ); + matchesExceptionMessage( containsString( "will be closed because the client did not consume outgoing buffers for " ) ) ) ); } } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/RequiredTransportEncryptionIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/RequiredTransportEncryptionIT.java index c28ed86edb926..55648874edae3 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/RequiredTransportEncryptionIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/RequiredTransportEncryptionIT.java @@ -19,7 +19,6 @@ */ package org.neo4j.bolt.v1.transport.integration; -import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -39,7 +38,9 @@ import org.neo4j.kernel.configuration.BoltConnector; import static java.util.Arrays.asList; +import static org.hamcrest.MatcherAssert.assertThat; import static org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket.DEFAULT_CONNECTOR_KEY; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects; import static org.neo4j.kernel.configuration.BoltConnector.EncryptionLevel.REQUIRED; @RunWith( Parameterized.class ) @@ -91,6 +92,6 @@ public void shouldCloseUnencryptedConnectionOnHandshakeWhenEncryptionIsRequired( client.connect( address ) .send( util.acceptedVersions( 1, 0, 0, 0 ) ); - MatcherAssert.assertThat( client, TransportTestUtil.eventuallyDisconnects() ); + assertThat( client, eventuallyDisconnects() ); } } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportErrorIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportErrorIT.java index a71fe4a37497f..6da096d4b7875 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportErrorIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportErrorIT.java @@ -19,7 +19,6 @@ */ package org.neo4j.bolt.v1.transport.integration; -import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -31,9 +30,11 @@ import org.neo4j.bolt.v1.packstream.BufferedChannelOutput; import org.neo4j.bolt.v1.packstream.PackStream; +import static org.hamcrest.MatcherAssert.assertThat; import static org.neo4j.bolt.v1.messaging.BoltRequestMessage.RUN; import static org.neo4j.bolt.v1.messaging.message.RunMessage.run; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.serialize; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects; public class TransportErrorIT extends AbstractBoltTransportsTest { @@ -59,8 +60,8 @@ public void shouldHandleIncorrectFraming() throws Throwable .send( util.chunk( 32, truncated ) ); // Then - MatcherAssert.assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -83,8 +84,8 @@ public void shouldHandleMessagesWithIncorrectFields() throws Throwable .send( util.chunk( 32, invalidMessage ) ); // Then - MatcherAssert.assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -106,8 +107,8 @@ public void shouldHandleUnknownMessages() throws Throwable .send( util.chunk( 32, invalidMessage ) ); // Then - MatcherAssert.assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -130,7 +131,7 @@ public void shouldHandleUnknownMarkerBytes() throws Throwable .send( util.chunk( 32, invalidMessage ) ); // Then - MatcherAssert.assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); + assertThat( connection, eventuallyDisconnects() ); } } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportSessionIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportSessionIT.java index 9c3fc362c35d6..5672d7aa0f505 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportSessionIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/TransportSessionIT.java @@ -31,11 +31,6 @@ import org.neo4j.bolt.AbstractBoltTransportsTest; import org.neo4j.bolt.v1.messaging.Neo4jPackV1; -import org.neo4j.bolt.v1.messaging.message.DiscardAllMessage; -import org.neo4j.bolt.v1.messaging.message.InitMessage; -import org.neo4j.bolt.v1.messaging.message.PullAllMessage; -import org.neo4j.bolt.v1.messaging.message.RunMessage; -import org.neo4j.bolt.v1.messaging.util.MessageMatchers; import org.neo4j.graphdb.InputPosition; import org.neo4j.graphdb.SeverityLevel; import org.neo4j.graphdb.factory.GraphDatabaseSettings; @@ -53,9 +48,17 @@ import static org.hamcrest.Matchers.hasKey; import static org.junit.Assume.assumeThat; import static org.neo4j.bolt.v1.messaging.message.AckFailureMessage.ackFailure; +import static org.neo4j.bolt.v1.messaging.message.DiscardAllMessage.discardAll; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; +import static org.neo4j.bolt.v1.messaging.message.PullAllMessage.pullAll; +import static org.neo4j.bolt.v1.messaging.message.RunMessage.run; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.hasNotification; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgFailure; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgIgnored; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgRecord; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; import static org.neo4j.bolt.v1.runtime.spi.StreamMatchers.eqRecord; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyReceives; import static org.neo4j.values.storable.Values.longValue; import static org.neo4j.values.storable.Values.stringValue; @@ -92,7 +95,7 @@ public void shouldReturnNilOnNoApplicableVersion() throws Throwable .send( util.acceptedVersions( 1337, 0, 0, 0 ) ); // Then - assertThat( connection, TransportTestUtil.eventuallyReceives( new byte[]{0, 0, 0, 0} ) ); + assertThat( connection, eventuallyReceives( new byte[]{0, 0, 0, 0} ) ); } @Test @@ -102,9 +105,9 @@ public void shouldRunSimpleStatement() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "UNWIND [1,2,3] AS a RETURN a, a * a AS a_squared" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "UNWIND [1,2,3] AS a RETURN a, a * a AS a_squared" ), + pullAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); @@ -127,9 +130,9 @@ public void shouldRespondWithMetadataToDiscardAll() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "UNWIND [1,2,3] AS a RETURN a, a * a AS a_squared" ), - DiscardAllMessage.discardAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "UNWIND [1,2,3] AS a RETURN a, a * a AS a_squared" ), + discardAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); @@ -148,20 +151,20 @@ public void shouldBeAbleToRunQueryAfterAckFailure() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "QINVALID" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "QINVALID" ), + pullAll() ) ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); assertThat( connection, util.eventuallyReceives( msgSuccess(), - MessageMatchers.msgFailure( Status.Statement.SyntaxError, + msgFailure( Status.Statement.SyntaxError, String.format( "Invalid input 'Q': expected (line 1, column 1 (offset: 0))%n" + "\"QINVALID\"%n" + - " ^" ) ), MessageMatchers.msgIgnored() ) ); + " ^" ) ), msgIgnored() ) ); // When - connection.send( util.chunk( ackFailure(), RunMessage.run( "RETURN 1" ), PullAllMessage.pullAll() ) ); + connection.send( util.chunk( ackFailure(), run( "RETURN 1" ), pullAll() ) ); // Then assertThat( connection, util.eventuallyReceives( @@ -178,9 +181,9 @@ public void shouldRunProcedure() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "CREATE (n:Test {age: 2}) RETURN n.age AS age" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "CREATE (n:Test {age: 2}) RETURN n.age AS age" ), + pullAll() ) ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); Matcher> ageMatcher = hasEntry( is( "fields" ), equalTo( singletonList( "age" ) ) ); @@ -192,8 +195,8 @@ public void shouldRunProcedure() throws Throwable // When connection.send( util.chunk( - RunMessage.run( "CALL db.labels() YIELD label" ), - PullAllMessage.pullAll() ) ); + run( "CALL db.labels() YIELD label" ), + pullAll() ) ); // Then Matcher> entryFieldsMatcher = hasEntry( is( "fields" ), equalTo( singletonList( "label" ) ) ); @@ -212,9 +215,9 @@ public void shouldHandleDeletedNodes() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "CREATE (n:Test) DELETE n RETURN n" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "CREATE (n:Test) DELETE n RETURN n" ), + pullAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); @@ -232,7 +235,7 @@ public void shouldHandleDeletedNodes() throws Throwable // props: {} (A)] //} assertThat( connection, - TransportTestUtil.eventuallyReceives( bytes( 0x00, 0x08, 0xB1, 0x71, 0x91, + eventuallyReceives( bytes( 0x00, 0x08, 0xB1, 0x71, 0x91, 0xB3, 0x4E, 0x00, 0x90, 0xA0, 0x00, 0x00 ) ) ); assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); } @@ -244,9 +247,9 @@ public void shouldHandleDeletedRelationships() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "CREATE ()-[r:T {prop: 42}]->() DELETE r RETURN r" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "CREATE ()-[r:T {prop: 42}]->() DELETE r RETURN r" ), + pullAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); @@ -266,7 +269,7 @@ public void shouldHandleDeletedRelationships() throws Throwable // props: {} (A0)] //} assertThat( connection, - TransportTestUtil.eventuallyReceives( bytes( 0x00, 0x0B, 0xB1, 0x71, 0x91, + eventuallyReceives( bytes( 0x00, 0x0B, 0xB1, 0x71, 0x91, 0xB5, 0x52, 0x00, 0x00, 0x01, 0x81, 0x54, 0xA0, 0x00, 0x00 ) ) ); assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); } @@ -278,9 +281,9 @@ public void shouldNotLeakStatsToNextStatement() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "CREATE (n)" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "CREATE (n)" ), + pullAll() ) ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); assertThat( connection, util.eventuallyReceives( msgSuccess(), @@ -290,8 +293,8 @@ public void shouldNotLeakStatsToNextStatement() throws Throwable // When connection.send( util.chunk( - RunMessage.run( "RETURN 1" ), - PullAllMessage.pullAll() ) ); + run( "RETURN 1" ), + pullAll() ) ); // Then Matcher> typeMatcher = hasEntry( is( "type" ), equalTo( "r" ) ); @@ -308,16 +311,16 @@ public void shouldSendNotifications() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "EXPLAIN MATCH (a:THIS_IS_NOT_A_LABEL) RETURN count(*)" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "EXPLAIN MATCH (a:THIS_IS_NOT_A_LABEL) RETURN count(*)" ), + pullAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); assertThat( connection, util.eventuallyReceives( msgSuccess(), msgSuccess(), - MessageMatchers.hasNotification( + hasNotification( new TestNotification( "Neo.ClientNotification.Statement.UnknownLabelWarning", "The provided label is not in the database.", "One of the labels in your query is not available in the database, " + @@ -338,9 +341,9 @@ public void shouldFailNicelyOnPointsWhenProtocolDoesNotSupportThem() throws Thro connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "RETURN point({x:13, y:37, crs:'cartesian'}) as p" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "RETURN point({x:13, y:37, crs:'cartesian'}) as p" ), + pullAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); @@ -348,7 +351,7 @@ public void shouldFailNicelyOnPointsWhenProtocolDoesNotSupportThem() throws Thro assertThat( connection, util.eventuallyReceives( msgSuccess(), msgSuccess( CoreMatchers.allOf( fieldsMatcher, hasKey( "result_available_after" ) ) ), - MessageMatchers.msgFailure( Status.Request.Invalid, "Point is not yet supported as a return type in Bolt" ) ) ); + msgFailure( Status.Request.Invalid, "Point is not yet supported as a return type in Bolt" ) ) ); } private byte[] bytes( int... ints ) @@ -375,19 +378,19 @@ public void shouldFailNicelyOnNullKeysInMap() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "RETURN {p}", ValueUtils.asMapValue( params ) ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "RETURN {p}", ValueUtils.asMapValue( params ) ), + pullAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); assertThat( connection, util.eventuallyReceives( msgSuccess(), - MessageMatchers.msgFailure( Status.Request.Invalid, + msgFailure( Status.Request.Invalid, "Value `null` is not supported as key in maps, must be a non-nullable string." ), - MessageMatchers.msgIgnored() ) ); + msgIgnored() ) ); - connection.send( util.chunk( ackFailure(), RunMessage.run( "RETURN 1" ), PullAllMessage.pullAll() ) ); + connection.send( util.chunk( ackFailure(), run( "RETURN 1" ), pullAll() ) ); // Then assertThat( connection, util.eventuallyReceives( @@ -404,16 +407,16 @@ public void shouldFailNicelyWhenDroppingUnknownIndex() throws Throwable connection.connect( address ) .send( util.defaultAcceptedVersions() ) .send( util.chunk( - InitMessage.init( "TestClient/1.1", emptyMap() ), - RunMessage.run( "DROP INDEX on :Movie12345(id)" ), - PullAllMessage.pullAll() ) ); + init( "TestClient/1.1", emptyMap() ), + run( "DROP INDEX on :Movie12345(id)" ), + pullAll() ) ); // Then assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); assertThat( connection, util.eventuallyReceives( msgSuccess(), - MessageMatchers.msgFailure( Status.Schema.IndexDropFailed, + msgFailure( Status.Schema.IndexDropFailed, "Unable to drop index on :Movie12345(id): No such INDEX ON :Movie12345(id)." ), - MessageMatchers.msgIgnored() ) ); + msgIgnored() ) ); } } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1IT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1IT.java index 138a5c3c2e326..ce10c9d40dd1a 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1IT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1IT.java @@ -40,8 +40,6 @@ import org.neo4j.bolt.v1.messaging.BoltRequestMessage; import org.neo4j.bolt.v1.messaging.Neo4jPack; import org.neo4j.bolt.v1.messaging.Neo4jPackV1; -import org.neo4j.bolt.v1.messaging.message.InitMessage; -import org.neo4j.bolt.v1.messaging.util.MessageMatchers; import org.neo4j.bolt.v1.packstream.PackedOutputArray; import org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection; import org.neo4j.bolt.v1.transport.socket.client.SecureWebSocketConnection; @@ -57,7 +55,10 @@ import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgFailure; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.auth_enabled; import static org.neo4j.values.storable.Values.pointValue; @@ -157,14 +158,14 @@ private void testFailureWithV2Value( AnyValue value, String description ) throws { connection.connect( address ).send( util.defaultAcceptedVersions() ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - connection.send( util.chunk( InitMessage.init( USER_AGENT, Collections.emptyMap() ) ) ); - assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) ); + connection.send( util.chunk( init( USER_AGENT, Collections.emptyMap() ) ) ); + assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); connection.send( util.chunk( 64, createRunWithV2Value( value ) ) ); assertThat( connection, util.eventuallyReceives( msgFailure( Status.Statement.TypeError, description + " values cannot be unpacked with this version of bolt." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } private byte[] createRunWithV2Value( AnyValue value ) throws IOException diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1V2IT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1V2IT.java index 97df3f617bd61..cfbcc66fc804e 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1V2IT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v1/transport/integration/UnsupportedStructTypesV1V2IT.java @@ -29,10 +29,6 @@ import org.neo4j.bolt.AbstractBoltTransportsTest; import org.neo4j.bolt.v1.messaging.BoltRequestMessage; import org.neo4j.bolt.v1.messaging.Neo4jPack; -import org.neo4j.bolt.v1.messaging.example.Edges; -import org.neo4j.bolt.v1.messaging.example.Nodes; -import org.neo4j.bolt.v1.messaging.example.Paths; -import org.neo4j.bolt.v1.messaging.message.InitMessage; import org.neo4j.bolt.v1.packstream.PackedOutputArray; import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.impl.util.ValueUtils; @@ -40,8 +36,13 @@ import org.neo4j.values.virtual.PathValue; import static org.hamcrest.MatcherAssert.assertThat; +import static org.neo4j.bolt.v1.messaging.example.Edges.ALICE_KNOWS_BOB; +import static org.neo4j.bolt.v1.messaging.example.Nodes.ALICE; +import static org.neo4j.bolt.v1.messaging.example.Paths.ALL_PATHS; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgFailure; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.auth_enabled; public class UnsupportedStructTypesV1V2IT extends AbstractBoltTransportsTest @@ -67,7 +68,7 @@ public void shouldFailWhenNullKeyIsSentWithInit() throws Exception assertThat( connection, util.eventuallyReceives( msgFailure( Status.Request.Invalid, "Value `null` is not supported as key in maps, must be a non-nullable string." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -79,7 +80,7 @@ public void shouldFailWhenDuplicateKeyIsSentWithInit() throws Exception connection.send( util.chunk( 64, createMsgWithDuplicateKey( BoltRequestMessage.INIT.signature() ) ) ); assertThat( connection, util.eventuallyReceives( msgFailure( Status.Request.Invalid, "Duplicate map key `key1`." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -87,14 +88,14 @@ public void shouldFailWhenNullKeyIsSentWithRun() throws Exception { connection.connect( address ).send( util.defaultAcceptedVersions() ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - connection.send( util.chunk( InitMessage.init( USER_AGENT, Collections.emptyMap() ) ) ); + connection.send( util.chunk( init( USER_AGENT, Collections.emptyMap() ) ) ); assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); connection.send( util.chunk( 64, createMsgWithNullKey( BoltRequestMessage.RUN.signature() ) ) ); assertThat( connection, util.eventuallyReceives( msgFailure( Status.Request.Invalid, "Value `null` is not supported as key in maps, must be a non-nullable string." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -102,31 +103,31 @@ public void shouldFailWhenDuplicateKeyIsSentWithRun() throws Exception { connection.connect( address ).send( util.defaultAcceptedVersions() ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - connection.send( util.chunk( InitMessage.init( USER_AGENT, Collections.emptyMap() ) ) ); + connection.send( util.chunk( init( USER_AGENT, Collections.emptyMap() ) ) ); assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); connection.send( util.chunk( 64, createMsgWithDuplicateKey( BoltRequestMessage.RUN.signature() ) ) ); assertThat( connection, util.eventuallyReceives( msgFailure( Status.Request.Invalid, "Duplicate map key `key1`." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test public void shouldFailWhenNodeIsSentWithRun() throws Exception { - testFailureWithV1Value( Nodes.ALICE, "Node" ); + testFailureWithV1Value( ALICE, "Node" ); } @Test public void shouldFailWhenRelationshipIsSentWithRun() throws Exception { - testFailureWithV1Value( Edges.ALICE_KNOWS_BOB, "Relationship" ); + testFailureWithV1Value( ALICE_KNOWS_BOB, "Relationship" ); } @Test public void shouldFailWhenPathIsSentWithRun() throws Exception { - for ( PathValue path : Paths.ALL_PATHS ) + for ( PathValue path : ALL_PATHS ) { try { @@ -144,12 +145,12 @@ public void shouldTerminateConnectionWhenUnknownMessageIsSent() throws Exception { connection.connect( address ).send( util.defaultAcceptedVersions() ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - connection.send( util.chunk( InitMessage.init( USER_AGENT, Collections.emptyMap() ) ) ); + connection.send( util.chunk( init( USER_AGENT, Collections.emptyMap() ) ) ); assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); connection.send( util.chunk( 64, createMsg( (byte)'A' ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } @Test @@ -157,26 +158,26 @@ public void shouldTerminateConnectionWhenUnknownTypeIsSent() throws Exception { connection.connect( address ).send( util.defaultAcceptedVersions() ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - connection.send( util.chunk( InitMessage.init( USER_AGENT, Collections.emptyMap() ) ) ); + connection.send( util.chunk( init( USER_AGENT, Collections.emptyMap() ) ) ); assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); connection.send( util.chunk( 64, createMsgWithUnknownValue( BoltRequestMessage.RUN.signature() ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } private void testFailureWithV1Value( AnyValue value, String description ) throws Exception { connection.connect( address ).send( util.defaultAcceptedVersions() ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - connection.send( util.chunk( InitMessage.init( USER_AGENT, Collections.emptyMap() ) ) ); + connection.send( util.chunk( init( USER_AGENT, Collections.emptyMap() ) ) ); assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); connection.send( util.chunk( 64, createRunWithV1Value( value ) ) ); assertThat( connection, util.eventuallyReceives( msgFailure( Status.Statement.TypeError, description + " values cannot be unpacked with this version of bolt." ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } private byte[] createRunWithV1Value( AnyValue value ) throws IOException diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/BoltV2TransportIT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/BoltV2TransportIT.java index 407e9a649dcd9..6e84248346ad8 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/BoltV2TransportIT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/BoltV2TransportIT.java @@ -19,7 +19,6 @@ */ package org.neo4j.bolt.v2.transport.integration; -import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -31,9 +30,6 @@ import java.time.ZoneOffset; import java.util.List; -import org.neo4j.bolt.v1.messaging.message.InitMessage; -import org.neo4j.bolt.v1.messaging.message.PullAllMessage; -import org.neo4j.bolt.v1.messaging.message.RunMessage; import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket; import org.neo4j.bolt.v1.transport.integration.TransportTestUtil; import org.neo4j.bolt.v1.transport.socket.client.SecureSocketConnection; @@ -48,10 +44,15 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptyMap; import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.runners.Parameterized.Parameters; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; +import static org.neo4j.bolt.v1.messaging.message.PullAllMessage.pullAll; +import static org.neo4j.bolt.v1.messaging.message.RunMessage.run; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgRecord; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; import static org.neo4j.bolt.v1.runtime.spi.StreamMatchers.eqRecord; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyReceives; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.auth_enabled; import static org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian; import static org.neo4j.values.storable.CoordinateReferenceSystem.WGS84; @@ -108,9 +109,9 @@ public void shouldNegotiateProtocolV2() throws Exception { connection.connect( address ) .send( util.acceptedVersions( 2, 0, 0, 0 ) ) - .send( util.chunk( InitMessage.init( USER_AGENT, emptyMap() ) ) ); + .send( util.chunk( init( USER_AGENT, emptyMap() ) ) ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyReceives( new byte[]{0, 0, 0, 2} ) ); + assertThat( connection, eventuallyReceives( new byte[]{0, 0, 0, 2} ) ); } @Test @@ -118,9 +119,9 @@ public void shouldNegotiateProtocolV2WhenClientSupportsBothV1AndV2() throws Exce { connection.connect( address ) .send( util.acceptedVersions( 2, 1, 0, 0 ) ) - .send( util.chunk( InitMessage.init( USER_AGENT, emptyMap() ) ) ); + .send( util.chunk( init( USER_AGENT, emptyMap() ) ) ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyReceives( new byte[]{0, 0, 0, 2} ) ); + assertThat( connection, eventuallyReceives( new byte[]{0, 0, 0, 2} ) ); } @Test @@ -274,10 +275,10 @@ private void testSendingOfBoltV2Value( T value ) throws Exc negotiateBoltV2(); connection.send( util.chunk( - RunMessage.run( "CREATE (n:Node {value: $value}) RETURN 42", map( new String[]{"value"}, new AnyValue[]{value} ) ), - PullAllMessage.pullAll() ) ); + run( "CREATE (n:Node {value: $value}) RETURN 42", map( new String[]{"value"}, new AnyValue[]{value} ) ), + pullAll() ) ); - MatcherAssert.assertThat( connection, util.eventuallyReceives( + assertThat( connection, util.eventuallyReceives( msgSuccess(), msgSuccess(), msgRecord( eqRecord( equalTo( longValue( 42 ) ) ) ), @@ -289,10 +290,10 @@ private void testReceivingOfBoltV2Value( String query, T ex negotiateBoltV2(); connection.send( util.chunk( - RunMessage.run( query ), - PullAllMessage.pullAll() ) ); + run( query ), + pullAll() ) ); - MatcherAssert.assertThat( connection, util.eventuallyReceives( + assertThat( connection, util.eventuallyReceives( msgSuccess(), msgSuccess(), msgRecord( eqRecord( equalTo( expectedValue ) ) ), @@ -304,10 +305,10 @@ private void testSendingAndReceivingOfBoltV2Value( T value negotiateBoltV2(); connection.send( util.chunk( - RunMessage.run( "RETURN $value", map( new String[]{"value"} , new AnyValue[]{value} ) ), - PullAllMessage.pullAll() ) ); + run( "RETURN $value", map( new String[]{"value"} , new AnyValue[]{value} ) ), + pullAll() ) ); - MatcherAssert.assertThat( connection, util.eventuallyReceives( + assertThat( connection, util.eventuallyReceives( msgSuccess(), msgSuccess(), msgRecord( eqRecord( equalTo( value ) ) ), @@ -318,8 +319,8 @@ private void negotiateBoltV2() throws Exception { connection.connect( address ) .send( util.acceptedVersions( 2, 0, 0, 0 ) ) - .send( util.chunk( InitMessage.init( USER_AGENT, emptyMap() ) ) ); + .send( util.chunk( init( USER_AGENT, emptyMap() ) ) ); - MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyReceives( new byte[]{0, 0, 0, 2} ) ); + assertThat( connection, eventuallyReceives( new byte[]{0, 0, 0, 2} ) ); } } diff --git a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/UnsupportedStructTypesV2IT.java b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/UnsupportedStructTypesV2IT.java index 28504d49be5c7..3f4846c5f58fb 100644 --- a/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/UnsupportedStructTypesV2IT.java +++ b/community/community-it/bolt-it/src/test/java/org/neo4j/bolt/v2/transport/integration/UnsupportedStructTypesV2IT.java @@ -33,8 +33,6 @@ import org.neo4j.bolt.messaging.StructType; import org.neo4j.bolt.v1.messaging.BoltRequestMessage; import org.neo4j.bolt.v1.messaging.Neo4jPack; -import org.neo4j.bolt.v1.messaging.message.InitMessage; -import org.neo4j.bolt.v1.messaging.util.MessageMatchers; import org.neo4j.bolt.v1.packstream.PackedOutputArray; import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket; import org.neo4j.bolt.v1.transport.integration.TransportTestUtil; @@ -52,7 +50,10 @@ import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; +import static org.neo4j.bolt.v1.messaging.message.InitMessage.init; import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgFailure; +import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess; +import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.auth_enabled; @RunWith( Parameterized.class ) @@ -159,26 +160,26 @@ private void testFailureWithUnpackableValue( ThrowingConsumer valuePacker, String expectedMessage ) throws Exception { connection.connect( address ).send( util.defaultAcceptedVersions() ); assertThat( connection, util.eventuallyReceivesSelectedProtocolVersion() ); - connection.send( util.chunk( InitMessage.init( USER_AGENT, Collections.emptyMap() ) ) ); - assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) ); + connection.send( util.chunk( init( USER_AGENT, Collections.emptyMap() ) ) ); + assertThat( connection, util.eventuallyReceives( msgSuccess() ) ); connection.send( util.chunk( 64, createRunWith( valuePacker ) ) ); - assertThat( connection, TransportTestUtil.eventuallyDisconnects() ); + assertThat( connection, eventuallyDisconnects() ); } private byte[] createRunWith( ThrowingConsumer valuePacker ) throws IOException diff --git a/community/community-it/community-it/src/test/java/org/neo4j/server/security/auth/AuthProceduresIT.java b/community/community-it/community-it/src/test/java/org/neo4j/server/security/auth/AuthProceduresIT.java index cb41c7cf2e539..562d1dd4a9ecc 100644 --- a/community/community-it/community-it/src/test/java/org/neo4j/server/security/auth/AuthProceduresIT.java +++ b/community/community-it/community-it/src/test/java/org/neo4j/server/security/auth/AuthProceduresIT.java @@ -19,7 +19,6 @@ */ package org.neo4j.server.security.auth; -import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -136,7 +135,7 @@ public void shouldCreateUser() assertEmpty( admin, "CALL dbms.security.createUser('andres', '123', true)" ); try { - MatcherAssert.assertThat( authManager.getUser( "andres" ).passwordChangeRequired(), equalTo( true ) ); + assertThat( authManager.getUser( "andres" ).passwordChangeRequired(), equalTo( true ) ); } catch ( Throwable t ) { @@ -150,7 +149,7 @@ public void shouldCreateUserWithNoPasswordChange() assertEmpty( admin, "CALL dbms.security.createUser('andres', '123', false)" ); try { - MatcherAssert.assertThat( authManager.getUser( "andres" ).passwordChangeRequired(), equalTo( false ) ); + assertThat( authManager.getUser( "andres" ).passwordChangeRequired(), equalTo( false ) ); } catch ( Throwable t ) { @@ -164,7 +163,7 @@ public void shouldCreateUserWithDefault() assertEmpty( admin, "CALL dbms.security.createUser('andres', '123')" ); try { - MatcherAssert.assertThat( authManager.getUser( "andres" ).passwordChangeRequired(), equalTo( true ) ); + assertThat( authManager.getUser( "andres" ).passwordChangeRequired(), equalTo( true ) ); } catch ( Throwable t ) { diff --git a/community/community-it/community-it/src/test/java/upgrade/StoreUpgradeOnStartupTest.java b/community/community-it/community-it/src/test/java/upgrade/StoreUpgradeOnStartupTest.java index 092f10fb67d59..265301c6a3966 100644 --- a/community/community-it/community-it/src/test/java/upgrade/StoreUpgradeOnStartupTest.java +++ b/community/community-it/community-it/src/test/java/upgrade/StoreUpgradeOnStartupTest.java @@ -39,7 +39,6 @@ import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.pagecache.PageCache; import org.neo4j.kernel.impl.store.format.standard.StandardV2_3; -import org.neo4j.kernel.impl.storemigration.MigrationTestUtils; import org.neo4j.kernel.impl.storemigration.StoreUpgrader; import org.neo4j.kernel.impl.storemigration.StoreVersionCheck; import org.neo4j.test.TestGraphDatabaseFactory; @@ -51,7 +50,9 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.neo4j.consistency.store.StoreAssertions.assertConsistentStore; +import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.checkNeoStoreHasDefaultFormatVersion; import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.prepareSampleLegacyDatabase; +import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.removeCheckPointFromTxLog; @RunWith( Parameterized.class ) public class StoreUpgradeOnStartupTest @@ -99,7 +100,7 @@ public void shouldUpgradeAutomaticallyOnDatabaseStartup() throws ConsistencyChec // then assertTrue( "Some store files did not have the correct version", - MigrationTestUtils.checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); + checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); assertConsistentStore( workingDirectory ); } @@ -107,7 +108,7 @@ public void shouldUpgradeAutomaticallyOnDatabaseStartup() throws ConsistencyChec public void shouldAbortOnNonCleanlyShutdown() throws Throwable { // given - MigrationTestUtils.removeCheckPointFromTxLog( fileSystem, workingDirectory ); + removeCheckPointFromTxLog( fileSystem, workingDirectory ); try { // when diff --git a/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java b/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java index 712d44b2994c7..29f695602bd51 100644 --- a/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java +++ b/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java @@ -71,6 +71,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.neo4j.consistency.store.StoreAssertions.assertConsistentStore; +import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.checkNeoStoreHasDefaultFormatVersion; @RunWith( Parameterized.class ) public class StoreUpgraderInterruptionTestIT @@ -149,7 +150,7 @@ public void migrate( File sourceStoreDir, File targetStoreDir, newUpgrader(upgradableDatabase, pageCache, progressMonitor, indexMigrator, migrator ).migrateIfNeeded( workingDirectory ); - assertTrue( MigrationTestUtils.checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); + assertTrue( checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); // Since consistency checker is in read only mode we need to start/stop db to generate label scan store. startStopDatabase( workingDirectory ); @@ -203,14 +204,14 @@ public void moveMigratedFiles( File migrationDir, File storeDir, String versionT assertEquals( "This upgrade is failing", e.getMessage() ); } - assertTrue( MigrationTestUtils.checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); + assertTrue( checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); progressMonitor = new SilentMigrationProgressMonitor(); StoreMigrator migrator = new StoreMigrator( fs, pageCache, CONFIG, logService ); newUpgrader( upgradableDatabase, pageCache, progressMonitor, createIndexMigrator(), migrator ) .migrateIfNeeded( workingDirectory ); - assertTrue( MigrationTestUtils.checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); + assertTrue( checkNeoStoreHasDefaultFormatVersion( check, workingDirectory ) ); pageCache.close(); diff --git a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceIntegrationTest.java b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceIntegrationTest.java index 5284c93d6d4b8..cb87633effc1d 100644 --- a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceIntegrationTest.java +++ b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceIntegrationTest.java @@ -56,7 +56,6 @@ import org.neo4j.kernel.impl.store.record.RelationshipRecord; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.logging.NullLogProvider; -import org.neo4j.test.Property; import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.rule.TestDirectory; @@ -71,6 +70,8 @@ import static org.neo4j.graphdb.factory.GraphDatabaseSettings.SchemaIndex.LUCENE10; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.SchemaIndex.NATIVE20; import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.test.Property.property; +import static org.neo4j.test.Property.set; public class ConsistencyCheckServiceIntegrationTest { @@ -81,8 +82,8 @@ protected void generateInitialData( GraphDatabaseService graphDb ) { try ( org.neo4j.graphdb.Transaction tx = graphDb.beginTx() ) { - Node node1 = Property.set( graphDb.createNode() ); - Node node2 = Property.set( graphDb.createNode(), Property.property( "key", "exampleValue" ) ); + Node node1 = set( graphDb.createNode() ); + Node node2 = set( graphDb.createNode(), property( "key", "exampleValue" ) ); node1.createRelationshipTo( node2, RelationshipType.withName( "C" ) ); tx.success(); } @@ -173,8 +174,8 @@ public void shouldNotReportDuplicateForHugeLongValues() throws Exception } try ( Transaction tx = db.beginTx() ) { - Property.set( db.createNode( label ), Property.property( propertyKey, 973305894188596880L ) ); - Property.set( db.createNode( label ), Property.property( propertyKey, 973305894188596864L ) ); + set( db.createNode( label ), property( propertyKey, 973305894188596880L ) ); + set( db.createNode( label ), property( propertyKey, 973305894188596864L ) ); tx.success(); } db.shutdown(); @@ -325,8 +326,8 @@ private void prepareDbWithDeletedRelationshipPartOfTheChain() RelationshipType relationshipType = RelationshipType.withName( "testRelationshipType" ); try ( Transaction tx = db.beginTx() ) { - Node node1 = Property.set( db.createNode() ); - Node node2 = Property.set( db.createNode(), Property.property( "key", "value" ) ); + Node node1 = set( db.createNode() ); + Node node2 = set( db.createNode(), property( "key", "value" ) ); node1.createRelationshipTo( node2, relationshipType ); node1.createRelationshipTo( node2, relationshipType ); node1.createRelationshipTo( node2, relationshipType ); diff --git a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/AllNodesInStoreExistInLabelIndexTest.java b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/AllNodesInStoreExistInLabelIndexTest.java index 69879fb46095a..7751ee12c17c0 100644 --- a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/AllNodesInStoreExistInLabelIndexTest.java +++ b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/AllNodesInStoreExistInLabelIndexTest.java @@ -42,7 +42,6 @@ import org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer; import org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo; import org.neo4j.logging.AssertableLogProvider; -import org.neo4j.test.TestLabels; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.EmbeddedDatabaseRule; import org.neo4j.test.rule.RandomRule; @@ -54,6 +53,9 @@ import static org.junit.Assert.assertTrue; import static org.neo4j.helpers.progress.ProgressMonitorFactory.NONE; import static org.neo4j.io.fs.FileUtils.copyFile; +import static org.neo4j.test.TestLabels.LABEL_ONE; +import static org.neo4j.test.TestLabels.LABEL_THREE; +import static org.neo4j.test.TestLabels.LABEL_TWO; public class AllNodesInStoreExistInLabelIndexTest { @@ -64,7 +66,7 @@ public class AllNodesInStoreExistInLabelIndexTest public final RandomRule random = new RandomRule(); private final AssertableLogProvider log = new AssertableLogProvider(); - private static final Label[] LABEL_ALPHABET = new Label[]{TestLabels.LABEL_ONE, TestLabels.LABEL_TWO, TestLabels.LABEL_THREE}; + private static final Label[] LABEL_ALPHABET = new Label[]{LABEL_ONE, LABEL_TWO, LABEL_THREE}; private static final Label EXTRA_LABEL = Label.label( "extra" ); private static final double DELETE_RATIO = 0.2; private static final double UPDATE_RATIO = 0.2; @@ -95,7 +97,7 @@ public void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncom try ( Transaction tx = db.beginTx() ) { - db.createNode( TestLabels.LABEL_ONE ); + db.createNode( LABEL_ONE ); tx.success(); } @@ -138,7 +140,7 @@ public void mustReportMissingNode() throws Exception // when try ( Transaction tx = db.beginTx() ) { - db.createNode( TestLabels.LABEL_ONE ); + db.createNode( LABEL_ONE ); tx.success(); } diff --git a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java index f72d9914b6f3a..f44c579b7a89d 100644 --- a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java +++ b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java @@ -43,7 +43,6 @@ import org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo; import org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap; import org.neo4j.logging.AssertableLogProvider; -import org.neo4j.test.TestLabels; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.EmbeddedDatabaseRule; import org.neo4j.test.rule.RandomRule; @@ -55,6 +54,9 @@ import static org.junit.Assert.assertTrue; import static org.neo4j.helpers.progress.ProgressMonitorFactory.NONE; import static org.neo4j.io.fs.FileUtils.copyRecursively; +import static org.neo4j.test.TestLabels.LABEL_ONE; +import static org.neo4j.test.TestLabels.LABEL_THREE; +import static org.neo4j.test.TestLabels.LABEL_TWO; public class IndexConsistencyIT { @@ -65,7 +67,7 @@ public class IndexConsistencyIT public final RandomRule random = new RandomRule(); private final AssertableLogProvider log = new AssertableLogProvider(); - private static final Label[] LABELS = new Label[]{TestLabels.LABEL_ONE, TestLabels.LABEL_TWO, TestLabels.LABEL_THREE}; + private static final Label[] LABELS = new Label[]{LABEL_ONE, LABEL_TWO, LABEL_THREE}; private static final String PROPERTY_KEY = "numericProperty"; private static final double DELETE_RATIO = 0.2; private static final double UPDATE_RATIO = 0.2; @@ -84,7 +86,7 @@ public void reportNotCleanNativeIndex() throws IOException, ConsistencyCheckInco try ( Transaction tx = db.beginTx() ) { - createNewNode( new Label[]{TestLabels.LABEL_ONE} ); + createNewNode( new Label[]{LABEL_ONE} ); tx.success(); } @@ -145,7 +147,7 @@ List> someData( int numberOfModifications ) } try ( Transaction tx = db.beginTx() ) { - db.schema().indexFor( TestLabels.LABEL_ONE ).on( PROPERTY_KEY ).create(); + db.schema().indexFor( LABEL_ONE ).on( PROPERTY_KEY ).create(); tx.success(); } try ( Transaction tx = db.beginTx() ) diff --git a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/ExecutionOrderIntegrationTest.java b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/ExecutionOrderIntegrationTest.java index 229c46de6572f..e1113a2e9bb2e 100644 --- a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/ExecutionOrderIntegrationTest.java +++ b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/ExecutionOrderIntegrationTest.java @@ -73,7 +73,6 @@ import org.neo4j.kernel.impl.store.record.RelationshipGroupRecord; import org.neo4j.kernel.impl.store.record.RelationshipRecord; import org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord; -import org.neo4j.test.Property; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; @@ -83,6 +82,8 @@ import static org.neo4j.consistency.report.ConsistencyReporter.NO_MONITOR; import static org.neo4j.graphdb.Label.label; import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.test.Property.property; +import static org.neo4j.test.Property.set; public class ExecutionOrderIntegrationTest { @@ -95,8 +96,8 @@ protected void generateInitialData( GraphDatabaseService graphDb ) // TODO: create bigger sample graph here try ( org.neo4j.graphdb.Transaction tx = graphDb.beginTx() ) { - Node node1 = Property.set( graphDb.createNode( label( "Foo" ) ) ); - Node node2 = Property.set( graphDb.createNode( label( "Foo" ) ), Property.property( "key", "value" ) ); + Node node1 = set( graphDb.createNode( label( "Foo" ) ) ); + Node node2 = set( graphDb.createNode( label( "Foo" ) ), property( "key", "value" ) ); node1.createRelationshipTo( node2, RelationshipType.withName( "C" ) ); tx.success(); } diff --git a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java index 1672e5a872a07..c65270a3f259e 100644 --- a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java +++ b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java @@ -47,7 +47,6 @@ import org.neo4j.consistency.checking.GraphStoreFixture.Applier; import org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator; import org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder; -import org.neo4j.consistency.checking.SchemaRuleUtil; import org.neo4j.consistency.report.ConsistencyReport; import org.neo4j.consistency.report.ConsistencySummaryStatistics; import org.neo4j.graphdb.DependencyResolver; @@ -109,7 +108,6 @@ import org.neo4j.logging.FormattedLog; import org.neo4j.storageengine.api.schema.SchemaRule; import org.neo4j.string.UTF8; -import org.neo4j.test.Property; import org.neo4j.test.rule.SuppressOutput; import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Values; @@ -124,6 +122,9 @@ import static org.neo4j.consistency.checking.RecordCheckTestBase.notInUse; import static org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule; import static org.neo4j.consistency.checking.SchemaRuleUtil.indexRule; +import static org.neo4j.consistency.checking.SchemaRuleUtil.nodePropertyExistenceConstraintRule; +import static org.neo4j.consistency.checking.SchemaRuleUtil.relPropertyExistenceConstraintRule; +import static org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule; import static org.neo4j.consistency.checking.full.FullCheckIntegrationTest.ConsistencySummaryVerifier.on; import static org.neo4j.graphdb.Label.label; import static org.neo4j.graphdb.RelationshipType.withName; @@ -147,6 +148,8 @@ import static org.neo4j.kernel.impl.store.record.Record.NO_PREV_RELATIONSHIP; import static org.neo4j.kernel.impl.store.record.RecordLoad.FORCE; import static org.neo4j.kernel.impl.util.Bits.bits; +import static org.neo4j.test.Property.property; +import static org.neo4j.test.Property.set; public class FullCheckIntegrationTest { @@ -242,16 +245,16 @@ protected void generateInitialData( GraphDatabaseService db ) try ( org.neo4j.graphdb.Transaction tx = db.beginTx() ) { - Node node1 = Property.set( db.createNode( label( "label1" ) ) ); - Node node2 = Property.set( db.createNode( label( "label2" ) ), Property.property( PROP1, VALUE1 ) ); + Node node1 = set( db.createNode( label( "label1" ) ) ); + Node node2 = set( db.createNode( label( "label2" ) ), property( PROP1, VALUE1 ) ); node1.createRelationshipTo( node2, withName( "C" ) ); // Just to create one more rel type db.createNode().createRelationshipTo( db.createNode(), withName( "T" ) ); - indexedNodes.add( Property.set( db.createNode( label( "label3" ) ), Property.property( PROP1, VALUE1 ) ).getId() ); - indexedNodes.add( Property.set( db.createNode( label( "label3" ) ), - Property.property( PROP1, VALUE1 ), Property.property( PROP2, VALUE2 ) ).getId() ); + indexedNodes.add( set( db.createNode( label( "label3" ) ), property( PROP1, VALUE1 ) ).getId() ); + indexedNodes.add( set( db.createNode( label( "label3" ) ), + property( PROP1, VALUE1 ), property( PROP2, VALUE2 ) ).getId() ); - Property.set( db.createNode( label( "label4" ) ), Property.property( PROP1, VALUE1 ) ); + set( db.createNode( label( "label4" ) ), property( PROP1, VALUE1 ) ); tx.success(); KernelTransaction ktx = transactionOn( db ); @@ -1092,7 +1095,7 @@ protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, DynamicRecord record2Before = record2.clone(); StoreIndexDescriptor rule1 = constraintIndexRule( ruleId1, labelId, propertyKeyId, DESCRIPTOR, ruleId2 ); - ConstraintRule rule2 = SchemaRuleUtil.uniquenessConstraintRule( ruleId2, labelId, propertyKeyId, ruleId2 ); + ConstraintRule rule2 = uniquenessConstraintRule( ruleId2, labelId, propertyKeyId, ruleId2 ); Collection records1 = serializeRule( rule1, record1 ); Collection records2 = serializeRule( rule2, record2 ); @@ -2290,14 +2293,14 @@ private void createNodeKeyConstraintRule( final int labelId, final int... proper private void createNodePropertyExistenceConstraint( int labelId, int propertyKeyId ) { SchemaStore schemaStore = (SchemaStore) fixture.directStoreAccess().nativeStores().getSchemaStore(); - ConstraintRule rule = SchemaRuleUtil.nodePropertyExistenceConstraintRule( schemaStore.nextId(), labelId, propertyKeyId ); + ConstraintRule rule = nodePropertyExistenceConstraintRule( schemaStore.nextId(), labelId, propertyKeyId ); writeToSchemaStore( schemaStore, rule ); } private void createRelationshipPropertyExistenceConstraint( int relTypeId, int propertyKeyId ) { SchemaStore schemaStore = (SchemaStore) fixture.directStoreAccess().nativeStores().getSchemaStore(); - ConstraintRule rule = SchemaRuleUtil.relPropertyExistenceConstraintRule( schemaStore.nextId(), relTypeId, propertyKeyId ); + ConstraintRule rule = relPropertyExistenceConstraintRule( schemaStore.nextId(), relTypeId, propertyKeyId ); writeToSchemaStore( schemaStore, rule ); } diff --git a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherLoggingTest.java b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherLoggingTest.java index e5e91970ed448..327ca3e41de63 100644 --- a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherLoggingTest.java +++ b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherLoggingTest.java @@ -55,7 +55,7 @@ public void shouldNotLogQueries() database.execute( "MATCH (n) RETURN n" ); // then - AssertableLogProvider.inLog( org.neo4j.cypher.internal.ExecutionEngine.class ); + inLog( org.neo4j.cypher.internal.ExecutionEngine.class ); logProvider.assertNoLoggingOccurred(); } } diff --git a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherUpdateMapTest.java b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherUpdateMapTest.java index e12e890ac6485..14e7b0c0e8692 100644 --- a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherUpdateMapTest.java +++ b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/CypherUpdateMapTest.java @@ -20,7 +20,6 @@ package org.neo4j.cypher.internal.javacompat; import org.hamcrest.Matcher; -import org.hamcrest.Matchers; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -29,11 +28,12 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; import org.neo4j.test.TestGraphDatabaseFactory; -import org.neo4j.test.mockito.matcher.Neo4jMatchers; +import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasProperty; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.inTx; public class CypherUpdateMapTest { @@ -63,14 +63,14 @@ public void updateNodeByMapParameter() Node node2 = getNodeByIdInTx( 0 ); - assertThat( node2, inTxS( Matchers.not( hasProperty( "key1" ) ) ) ); - assertThat( node2, inTxS( Matchers.not( hasProperty( "key2" ) ) ) ); + assertThat( node2, inTxS( not( hasProperty( "key1" ) ) ) ); + assertThat( node2, inTxS( not( hasProperty( "key2" ) ) ) ); assertThat( node2, inTxS( hasProperty( "key3" ).withValue(5678) ) ); } public Matcher inTxS( final Matcher inner ) { - return Neo4jMatchers.inTx( db, inner, false ); + return inTx( db, inner, false ); } private Node getNodeByIdInTx( int nodeId ) diff --git a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/EagerResultIT.java b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/EagerResultIT.java index 674defb36bacf..aecd42f6d0a63 100644 --- a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/EagerResultIT.java +++ b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/EagerResultIT.java @@ -19,9 +19,7 @@ */ package org.neo4j.cypher.internal.javacompat; -import org.hamcrest.Matchers; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -66,7 +64,12 @@ import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.rule.TestDirectory; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class EagerResultIT { @@ -148,7 +151,7 @@ public void eagerResultHaveQueryStatistic() { Result result = database.execute( "MATCH (n) RETURN n.c" ); assertEquals( 1, testCursorContext.getAdditionalAttempts() ); - Assert.assertFalse( result.getQueryStatistics().containsUpdates() ); + assertFalse( result.getQueryStatistics().containsUpdates() ); } @Test @@ -173,9 +176,9 @@ public void eagerResultToString() Result result = database.execute( "MATCH (n) RETURN n.c, n.d" ); assertEquals( 1, testCursorContext.getAdditionalAttempts() ); String resultString = result.resultAsString(); - Assert.assertTrue( resultString.contains( "n.c, n.d" ) ); - Assert.assertTrue( resultString.contains( "d, a" ) ); - Assert.assertTrue( resultString.contains( "y, k" ) ); + assertTrue( resultString.contains( "n.c, n.d" ) ); + assertTrue( resultString.contains( "d, a" ) ); + assertTrue( resultString.contains( "y, k" ) ); } @Test @@ -196,8 +199,8 @@ public void eagerResultVisit() throws Exception values.add( row.getString( "n.c" ) ); return false; } ); - Assert.assertThat( values, Matchers.hasSize( 2 ) ); - Assert.assertThat( values, Matchers.containsInAnyOrder( "d", "y" ) ); + assertThat( values, hasSize( 2 ) ); + assertThat( values, containsInAnyOrder( "d", "y" ) ); } @Test( expected = QueryExecutionException.class ) diff --git a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionEngineTest.java b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionEngineTest.java index 8325b503b1243..17ebc4918ed7b 100644 --- a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionEngineTest.java +++ b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionEngineTest.java @@ -19,7 +19,6 @@ */ package org.neo4j.cypher.internal.javacompat; -import org.hamcrest.core.Is; import org.junit.Rule; import org.junit.Test; @@ -44,6 +43,7 @@ import org.neo4j.values.virtual.MapValue; import org.neo4j.values.virtual.VirtualValues; +import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.neo4j.values.virtual.VirtualValues.EMPTY_MAP; @@ -83,10 +83,10 @@ public void shouldConvertListsAndMapsWhenPassingFromScalaToJava() throws Excepti private void verifyResult( Result result ) { Map firstRowValue = (Map) result.next().values().iterator().next(); - assertThat( firstRowValue.get( "key" ), Is.is( "Value" ) ); + assertThat( firstRowValue.get( "key" ), is( "Value" ) ); List theList = (List) firstRowValue.get( "collectionKey" ); - assertThat( ((Map) theList.get( 0 )).get( "inner" ), Is.is( "Map1" ) ); - assertThat( ((Map) theList.get( 1 )).get( "inner" ), Is.is( "Map2" ) ); + assertThat( ((Map) theList.get( 0 )).get( "inner" ), is( "Map1" ) ); + assertThat( ((Map) theList.get( 1 )).get( "inner" ), is( "Map2" ) ); } private TransactionalContext createTransactionContext( GraphDatabaseQueryService graph, InternalTransaction tx, diff --git a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionResultTest.java b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionResultTest.java index 6a57483a41d10..2f55f0cc30645 100644 --- a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionResultTest.java +++ b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/ExecutionResultTest.java @@ -19,7 +19,6 @@ */ package org.neo4j.cypher.internal.javacompat; -import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; @@ -39,6 +38,7 @@ import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; @@ -95,8 +95,8 @@ public void shouldThrowAppropriateException() } catch ( QueryExecutionException ex ) { - assertThat( ex.getCause(), Matchers.instanceOf( QueryExecutionKernelException.class ) ); - assertThat( ex.getCause().getCause(), Matchers.instanceOf( ArithmeticException.class ) ); + assertThat( ex.getCause(), instanceOf( QueryExecutionKernelException.class ) ); + assertThat( ex.getCause().getCause(), instanceOf( ArithmeticException.class ) ); } } diff --git a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java index afa2bd25b616f..50229a0edc8d8 100644 --- a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java +++ b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/NotificationAcceptanceTest.java @@ -50,6 +50,7 @@ import static org.hamcrest.Matchers.any; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import static org.neo4j.graphdb.Label.label; @@ -936,7 +937,7 @@ private void shouldNotNotifyInStream( String version, String query ) Result result = db().execute( version + query ); // then - assertThat( Iterables.asList( result.getNotifications() ), Matchers.empty() ); + assertThat( Iterables.asList( result.getNotifications() ), empty() ); Map arguments = result.getExecutionPlanDescription().getArguments(); assertThat( arguments.get( "version" ), equalTo( version ) ); result.close(); diff --git a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java index 4366c28a9aae2..c3e474adbabf5 100644 --- a/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java +++ b/community/community-it/cypher-it/src/test/java/org/neo4j/cypher/internal/javacompat/SnapshotExecutionEngineTest.java @@ -22,8 +22,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.mockito.ArgumentMatchers; -import org.mockito.Mockito; import java.util.Collections; @@ -42,8 +40,12 @@ import org.neo4j.test.rule.ImpermanentDatabaseRule; import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class SnapshotExecutionEngineTest { @@ -69,12 +71,12 @@ public void setUp() throws Exception versionContext = mock( VersionContext.class ); executionEngine = createExecutionEngine(cypherService); - Mockito.when( kernelStatement.getVersionContext() ).thenReturn( versionContext ); - Mockito.when( transactionalContext.statement() ).thenReturn( kernelStatement ); + when( kernelStatement.getVersionContext() ).thenReturn( versionContext ); + when( transactionalContext.statement() ).thenReturn( kernelStatement ); Result result = mock( Result.class ); QueryStatistics statistics = mock( QueryStatistics.class ); - Mockito.when( result.getQueryStatistics() ).thenReturn( statistics ); - Mockito.when( executor.execute( ArgumentMatchers.any(), ArgumentMatchers.anyMap(), ArgumentMatchers.any() ) ).thenReturn( result ); + when( result.getQueryStatistics() ).thenReturn( statistics ); + when( executor.execute( any(), anyMap(), any() ) ).thenReturn( result ); } @Test @@ -82,25 +84,25 @@ public void executeQueryWithoutRetries() throws QueryExecutionKernelException { executionEngine.executeWithRetries( "query", Collections.emptyMap(), transactionalContext, executor ); - verify( executor, Mockito.times( 1 ) ).execute( ArgumentMatchers.any(), ArgumentMatchers.anyMap(), ArgumentMatchers.any() ); - verify( versionContext, Mockito.times( 1 ) ).initRead(); + verify( executor, times( 1 ) ).execute( any(), anyMap(), any() ); + verify( versionContext, times( 1 ) ).initRead(); } @Test public void executeQueryAfterSeveralRetries() throws QueryExecutionKernelException { - Mockito.when( versionContext.isDirty() ).thenReturn( true, true, false ); + when( versionContext.isDirty() ).thenReturn( true, true, false ); executionEngine.executeWithRetries( "query", Collections.emptyMap(), transactionalContext, executor ); - verify( executor, Mockito.times( 3 ) ).execute( ArgumentMatchers.any(), ArgumentMatchers.anyMap(), ArgumentMatchers.any() ); - verify( versionContext, Mockito.times( 3 ) ).initRead(); + verify( executor, times( 3 ) ).execute( any(), anyMap(), any() ); + verify( versionContext, times( 3 ) ).initRead(); } @Test public void failQueryAfterMaxRetriesReached() throws QueryExecutionKernelException { - Mockito.when( versionContext.isDirty() ).thenReturn( true ); + when( versionContext.isDirty() ).thenReturn( true ); try { @@ -111,8 +113,8 @@ public void failQueryAfterMaxRetriesReached() throws QueryExecutionKernelExcepti assertEquals( "Unable to get clean data snapshot for query 'query' after 5 attempts.", e.getMessage() ); } - verify( executor, Mockito.times( 5 ) ).execute( ArgumentMatchers.any(), ArgumentMatchers.anyMap(), ArgumentMatchers.any() ); - verify( versionContext, Mockito.times( 5 ) ).initRead(); + verify( executor, times( 5 ) ).execute( any(), anyMap(), any() ); + verify( versionContext, times( 5 ) ).initRead(); } private class TestSnapshotExecutionEngine extends SnapshotExecutionEngine diff --git a/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DatabaseImporterTest.java b/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DatabaseImporterTest.java index 4c07ce50264f6..de0efefc75b7a 100644 --- a/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DatabaseImporterTest.java +++ b/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DatabaseImporterTest.java @@ -22,8 +22,6 @@ import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; -import org.hamcrest.core.IsNot; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -42,7 +40,10 @@ import org.neo4j.test.rule.TestDirectory; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.core.IsNot.not; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public class DatabaseImporterTest @@ -96,7 +97,7 @@ public void copiesDatabaseFromOldLocationToNewLocation() throws Exception DatabaseImporter importer = new DatabaseImporter( Args.parse( arguments ), getConfigWith( home, "bar" ), new NullOutsideWorld() ); - assertThat( destination, IsNot.not( isExistingDatabase() ) ); + assertThat( destination, not( isExistingDatabase() ) ); importer.doImport(); assertThat( destination, isExistingDatabase() ); } @@ -109,7 +110,7 @@ public void removesOldMessagesLog() throws Exception File from = provideStoreDirectory(); File oldMessagesLog = new File( from, "messages.log" ); - Assert.assertTrue( oldMessagesLog.createNewFile() ); + assertTrue( oldMessagesLog.createNewFile() ); File destination = new File( new File( new File( home, "data" ), "databases" ), "bar" ); @@ -119,7 +120,7 @@ public void removesOldMessagesLog() throws Exception File messagesLog = new File( destination, "messages.log" ); importer.doImport(); - Assert.assertFalse( messagesLog.exists() ); + assertFalse( messagesLog.exists() ); } private Config getConfigWith( File homeDir, String databaseName ) diff --git a/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DiagnosticsReportCommandIT.java b/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DiagnosticsReportCommandIT.java index 8bfb5445f174d..a52a6b20e8f14 100644 --- a/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DiagnosticsReportCommandIT.java +++ b/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/DiagnosticsReportCommandIT.java @@ -19,7 +19,6 @@ */ package org.neo4j.commandline.dbms; -import org.hamcrest.CoreMatchers; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -43,8 +42,10 @@ import org.neo4j.test.rule.SuppressOutput; import org.neo4j.test.rule.TestDirectory; +import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; public class DiagnosticsReportCommandIT @@ -103,7 +104,7 @@ public void shouldBeAbleToAttachToPidAndRunThreadDump() throws IOException, Comm // Verify that we took a thread dump File reports = testDirectory.directory( "reports" ); File[] files = reports.listFiles(); - assertThat( files, CoreMatchers.notNullValue() ); + assertThat( files, notNullValue() ); assertThat( files.length, is( 1 ) ); Path report = files[0].toPath(); @@ -112,7 +113,7 @@ public void shouldBeAbleToAttachToPidAndRunThreadDump() throws IOException, Comm try ( FileSystem fs = FileSystems.newFileSystem( uri, Collections.emptyMap() ) ) { String threadDump = new String( Files.readAllBytes( fs.getPath( "threaddump.txt" ) ) ); - assertThat( threadDump, CoreMatchers.containsString( DiagnosticsReportCommandIT.class.getCanonicalName() ) ); + assertThat( threadDump, containsString( DiagnosticsReportCommandIT.class.getCanonicalName() ) ); } } diff --git a/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/MemoryRecommendationsCommandTest.java b/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/MemoryRecommendationsCommandTest.java index b89a913ba2a73..d4f447f0a1abb 100644 --- a/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/MemoryRecommendationsCommandTest.java +++ b/community/community-it/dbms-it/src/test/java/org/neo4j/commandline/dbms/MemoryRecommendationsCommandTest.java @@ -21,7 +21,6 @@ import org.apache.commons.lang3.mutable.MutableLong; import org.hamcrest.Matcher; -import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; @@ -38,33 +37,50 @@ import org.neo4j.commandline.admin.OutsideWorld; import org.neo4j.commandline.admin.RealOutsideWorld; -import org.neo4j.configuration.ExternalSettings; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.config.Setting; -import org.neo4j.graphdb.factory.GraphDatabaseSettings; -import org.neo4j.helpers.ArrayUtil; -import org.neo4j.helpers.collection.MapUtil; -import org.neo4j.io.ByteUnit; import org.neo4j.kernel.api.impl.index.storage.FailureStorage; import org.neo4j.kernel.api.index.IndexDirectoryStructure; -import org.neo4j.kernel.configuration.Config; -import org.neo4j.kernel.configuration.Settings; import org.neo4j.kernel.impl.store.StoreType; import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.rule.TestDirectory; import org.neo4j.values.storable.RandomValues; import org.neo4j.values.storable.Value; +import static org.hamcrest.Matchers.both; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.junit.Assert.assertThat; import static org.neo4j.commandline.dbms.MemoryRecommendationsCommand.bytesToString; +import static org.neo4j.commandline.dbms.MemoryRecommendationsCommand.recommendHeapMemory; import static org.neo4j.commandline.dbms.MemoryRecommendationsCommand.recommendOsMemory; +import static org.neo4j.commandline.dbms.MemoryRecommendationsCommand.recommendPageCacheMemory; +import static org.neo4j.configuration.ExternalSettings.initialHeapSize; +import static org.neo4j.configuration.ExternalSettings.maxHeapSize; +import static org.neo4j.graphdb.factory.GraphDatabaseSettings.SchemaIndex; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.active_database; +import static org.neo4j.graphdb.factory.GraphDatabaseSettings.data_directory; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.database_path; +import static org.neo4j.graphdb.factory.GraphDatabaseSettings.default_schema_provider; +import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_memory; +import static org.neo4j.helpers.ArrayUtil.array; +import static org.neo4j.helpers.collection.MapUtil.load; +import static org.neo4j.helpers.collection.MapUtil.store; +import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.io.ByteUnit.exbiBytes; import static org.neo4j.io.ByteUnit.gibiBytes; import static org.neo4j.io.ByteUnit.mebiBytes; +import static org.neo4j.io.ByteUnit.tebiBytes; +import static org.neo4j.kernel.configuration.Config.DEFAULT_CONFIG_FILE_NAME; +import static org.neo4j.kernel.configuration.Config.fromFile; +import static org.neo4j.kernel.configuration.Settings.BYTES; +import static org.neo4j.kernel.configuration.Settings.buildSetting; public class MemoryRecommendationsCommandTest { @@ -78,38 +94,38 @@ public void mustRecommendOSMemory() assertThat( recommendOsMemory( gibiBytes( 1 ) ), between( mebiBytes( 450 ), mebiBytes( 550 ) ) ); assertThat( recommendOsMemory( gibiBytes( 3 ) ), between( mebiBytes( 1256 ), mebiBytes( 1356 ) ) ); assertThat( recommendOsMemory( gibiBytes( 192 ) ), between( gibiBytes( 17 ), gibiBytes( 19 ) ) ); - assertThat( recommendOsMemory( gibiBytes( 1920 ) ), Matchers.greaterThan( gibiBytes( 29 ) ) ); + assertThat( recommendOsMemory( gibiBytes( 1920 ) ), greaterThan( gibiBytes( 29 ) ) ); } @Test public void mustRecommendHeapMemory() { - assertThat( MemoryRecommendationsCommand.recommendHeapMemory( mebiBytes( 100 ) ), between( mebiBytes( 45 ), mebiBytes( 55 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendHeapMemory( gibiBytes( 1 ) ), between( mebiBytes( 450 ), mebiBytes( 550 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendHeapMemory( gibiBytes( 3 ) ), between( mebiBytes( 1256 ), mebiBytes( 1356 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendHeapMemory( gibiBytes( 6 ) ), between( mebiBytes( 3000 ), mebiBytes( 3200 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendHeapMemory( gibiBytes( 192 ) ), between( gibiBytes( 30 ), gibiBytes( 32 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendHeapMemory( gibiBytes( 1920 ) ), between( gibiBytes( 30 ), gibiBytes( 32 ) ) ); + assertThat( recommendHeapMemory( mebiBytes( 100 ) ), between( mebiBytes( 45 ), mebiBytes( 55 ) ) ); + assertThat( recommendHeapMemory( gibiBytes( 1 ) ), between( mebiBytes( 450 ), mebiBytes( 550 ) ) ); + assertThat( recommendHeapMemory( gibiBytes( 3 ) ), between( mebiBytes( 1256 ), mebiBytes( 1356 ) ) ); + assertThat( recommendHeapMemory( gibiBytes( 6 ) ), between( mebiBytes( 3000 ), mebiBytes( 3200 ) ) ); + assertThat( recommendHeapMemory( gibiBytes( 192 ) ), between( gibiBytes( 30 ), gibiBytes( 32 ) ) ); + assertThat( recommendHeapMemory( gibiBytes( 1920 ) ), between( gibiBytes( 30 ), gibiBytes( 32 ) ) ); } @Test public void mustRecommendPageCacheMemory() { - assertThat( MemoryRecommendationsCommand.recommendPageCacheMemory( mebiBytes( 100 ) ), between( mebiBytes( 95 ), mebiBytes( 105 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendPageCacheMemory( gibiBytes( 1 ) ), between( mebiBytes( 95 ), mebiBytes( 105 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendPageCacheMemory( gibiBytes( 3 ) ), between( mebiBytes( 470 ), mebiBytes( 530 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendPageCacheMemory( gibiBytes( 6 ) ), between( mebiBytes( 980 ), mebiBytes( 1048 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendPageCacheMemory( gibiBytes( 192 ) ), between( gibiBytes( 140 ), gibiBytes( 150 ) ) ); - assertThat( MemoryRecommendationsCommand.recommendPageCacheMemory( gibiBytes( 1920 ) ), between( gibiBytes( 1850 ), gibiBytes( 1900 ) ) ); + assertThat( recommendPageCacheMemory( mebiBytes( 100 ) ), between( mebiBytes( 95 ), mebiBytes( 105 ) ) ); + assertThat( recommendPageCacheMemory( gibiBytes( 1 ) ), between( mebiBytes( 95 ), mebiBytes( 105 ) ) ); + assertThat( recommendPageCacheMemory( gibiBytes( 3 ) ), between( mebiBytes( 470 ), mebiBytes( 530 ) ) ); + assertThat( recommendPageCacheMemory( gibiBytes( 6 ) ), between( mebiBytes( 980 ), mebiBytes( 1048 ) ) ); + assertThat( recommendPageCacheMemory( gibiBytes( 192 ) ), between( gibiBytes( 140 ), gibiBytes( 150 ) ) ); + assertThat( recommendPageCacheMemory( gibiBytes( 1920 ) ), between( gibiBytes( 1850 ), gibiBytes( 1900 ) ) ); // Also never recommend more than 16 TiB of page cache memory, regardless of how much is available. - assertThat( MemoryRecommendationsCommand.recommendPageCacheMemory( ByteUnit.exbiBytes( 1 ) ), Matchers.lessThan( ByteUnit.tebiBytes( 17 ) ) ); + assertThat( recommendPageCacheMemory( exbiBytes( 1 ) ), lessThan( tebiBytes( 17 ) ) ); } @Test public void bytesToStringMustBeParseableBySettings() { - Setting setting = Settings.buildSetting( "arg", Settings.BYTES ).build(); + Setting setting = buildSetting( "arg", BYTES ).build(); for ( int i = 1; i < 10_000; i++ ) { int mebibytes = 75 * i; @@ -125,7 +141,7 @@ public void bytesToStringMustBeParseableBySettings() private Matcher between( long lowerBound, long upperBound ) { - return Matchers.both( Matchers.greaterThanOrEqualTo( lowerBound ) ).and( Matchers.lessThanOrEqualTo( upperBound ) ); + return both( greaterThanOrEqualTo( lowerBound ) ).and( lessThanOrEqualTo( upperBound ) ); } @Test @@ -143,15 +159,15 @@ public void stdOutLine( String text ) } }; MemoryRecommendationsCommand command = new MemoryRecommendationsCommand( homeDir, configDir, outsideWorld ); - String heap = bytesToString( MemoryRecommendationsCommand.recommendHeapMemory( gibiBytes( 8 ) ) ); - String pagecache = bytesToString( MemoryRecommendationsCommand.recommendPageCacheMemory( gibiBytes( 8 ) ) ); + String heap = bytesToString( recommendHeapMemory( gibiBytes( 8 ) ) ); + String pagecache = bytesToString( recommendPageCacheMemory( gibiBytes( 8 ) ) ); command.execute( new String[]{"--memory=8g"} ); - Map stringMap = MapUtil.load( new StringReader( output.toString() ) ); - assertThat( stringMap.get( ExternalSettings.initialHeapSize.name() ), Matchers.is( heap ) ); - assertThat( stringMap.get( ExternalSettings.maxHeapSize.name() ), Matchers.is( heap ) ); - assertThat( stringMap.get( GraphDatabaseSettings.pagecache_memory.name() ), Matchers.is( pagecache ) ); + Map stringMap = load( new StringReader( output.toString() ) ); + assertThat( stringMap.get( initialHeapSize.name() ), is( heap ) ); + assertThat( stringMap.get( maxHeapSize.name() ), is( heap ) ); + assertThat( stringMap.get( pagecache_memory.name() ), is( pagecache ) ); } @Test @@ -162,10 +178,10 @@ public void mustPrintMinimalPageCacheMemorySettingForConfiguredDb() throws Excep Path homeDir = directory.directory().toPath(); Path configDir = homeDir.resolve( "conf" ); configDir.toFile().mkdirs(); - Path configFile = configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ); + Path configFile = configDir.resolve( DEFAULT_CONFIG_FILE_NAME ); String databaseName = "mydb"; - MapUtil.store( MapUtil.stringMap( GraphDatabaseSettings.data_directory.name(), homeDir.toString() ), configFile.toFile() ); - File storeDir = Config.fromFile( configFile ).withHome( homeDir ).withSetting( active_database, databaseName ).build().get( database_path ); + store( stringMap( data_directory.name(), homeDir.toString() ), configFile.toFile() ); + File storeDir = fromFile( configFile ).withHome( homeDir ).withSetting( active_database, databaseName ).build().get( database_path ); createDatabaseWithNativeIndexes( storeDir ); OutsideWorld outsideWorld = new RealOutsideWorld() { @@ -176,18 +192,18 @@ public void stdOutLine( String text ) } }; MemoryRecommendationsCommand command = new MemoryRecommendationsCommand( homeDir, configDir, outsideWorld ); - String heap = bytesToString( MemoryRecommendationsCommand.recommendHeapMemory( gibiBytes( 8 ) ) ); - String pagecache = bytesToString( MemoryRecommendationsCommand.recommendPageCacheMemory( gibiBytes( 8 ) ) ); + String heap = bytesToString( recommendHeapMemory( gibiBytes( 8 ) ) ); + String pagecache = bytesToString( recommendPageCacheMemory( gibiBytes( 8 ) ) ); // when - command.execute( ArrayUtil.array( "--database", databaseName, "--memory", "8g" ) ); + command.execute( array( "--database", databaseName, "--memory", "8g" ) ); // then String memrecString = output.toString(); - Map stringMap = MapUtil.load( new StringReader( memrecString ) ); - assertThat( stringMap.get( ExternalSettings.initialHeapSize.name() ), Matchers.is( heap ) ); - assertThat( stringMap.get( ExternalSettings.maxHeapSize.name() ), Matchers.is( heap ) ); - assertThat( stringMap.get( GraphDatabaseSettings.pagecache_memory.name() ), Matchers.is( pagecache ) ); + Map stringMap = load( new StringReader( memrecString ) ); + assertThat( stringMap.get( initialHeapSize.name() ), is( heap ) ); + assertThat( stringMap.get( maxHeapSize.name() ), is( heap ) ); + assertThat( stringMap.get( pagecache_memory.name() ), is( pagecache ) ); long[] expectedSizes = calculatePageCacheFileSize( storeDir ); long expectedPageCacheSize = expectedSizes[0]; @@ -232,10 +248,10 @@ public FileVisitResult visitFile( Path path, BasicFileAttributes attrs ) throws private void createDatabaseWithNativeIndexes( File storeDir ) { // Create one index for every provider that we have - for ( GraphDatabaseSettings.SchemaIndex schemaIndex : GraphDatabaseSettings.SchemaIndex.values() ) + for ( SchemaIndex schemaIndex : SchemaIndex.values() ) { GraphDatabaseService db = - new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir ).setConfig( GraphDatabaseSettings.default_schema_provider, + new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir ).setConfig( default_schema_provider, schemaIndex.providerName() ).newGraphDatabase(); String key = "key-" + schemaIndex.name(); try diff --git a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java index d9e4f4d122eda..00e66ab522e31 100644 --- a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java +++ b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java @@ -37,6 +37,8 @@ import org.neo4j.unsafe.impl.batchimport.input.InputException; import static org.junit.Assert.fail; +import static org.neo4j.tooling.ImportToolTest.assertExceptionContains; +import static org.neo4j.tooling.ImportToolTest.importTool; /** * Tests that we fail correctly when given strings which can't be interpreted as numbers when configured to interpret @@ -113,13 +115,13 @@ public void test() throws Exception try { // WHEN - ImportToolTest.importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--quote", "'", "--nodes", data.getAbsolutePath() ); + importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--quote", "'", "--nodes", data.getAbsolutePath() ); // THEN fail( "Expected import to fail" ); } catch ( Exception e ) { - ImportToolTest.assertExceptionContains( e, expectedError, InputException.class ); + assertExceptionContains( e, expectedError, InputException.class ); } } diff --git a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java index f204b486200f1..188a8e6e83f02 100644 --- a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java +++ b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java @@ -20,7 +20,6 @@ package org.neo4j.tooling; import org.apache.commons.lang3.mutable.MutableInt; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -77,7 +76,12 @@ import static java.util.stream.Collectors.joining; import static org.apache.commons.lang3.StringUtils.repeat; import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.neo4j.graphdb.Label.label; import static org.neo4j.graphdb.RelationshipType.withName; import static org.neo4j.helpers.ArrayUtil.join; @@ -199,13 +203,13 @@ public void import4097Labels() throws Exception try ( Transaction tx = dbRule.beginTx() ) { long nodeCount = Iterables.count( dbRule.getAllNodes() ); - Assert.assertEquals( 4097, nodeCount ); + assertEquals( 4097, nodeCount ); tx.success(); ResourceIterator nodes = dbRule.findNodes( label( "FIRST 4096" ) ); - Assert.assertEquals( 1, Iterators.asList( nodes ).size() ); + assertEquals( 1, Iterators.asList( nodes ).size() ); nodes = dbRule.findNodes( label( "SECOND 4096" ) ); - Assert.assertEquals( 1, Iterators.asList( nodes ).size() ); + assertEquals( 1, Iterators.asList( nodes ).size() ); } } @@ -250,7 +254,7 @@ public void shouldIgnoreWhitespaceAroundIntegers() throws Exception String expected = name.trim(); - Assert.assertEquals( 7, node.getAllProperties().size() ); + assertEquals( 7, node.getAllProperties().size() ); for ( String key : node.getPropertyKeys() ) { if ( key.equals( "name" ) ) @@ -263,14 +267,14 @@ else if ( key.equals( "f" ) || key.equals( "d" ) ) expected = String.valueOf( Double.parseDouble( expected ) ); } - Assert.assertEquals( "Wrong value for " + key, expected, node.getProperty( key ).toString() ); + assertEquals( "Wrong value for " + key, expected, node.getProperty( key ).toString() ); } } tx.success(); } - Assert.assertEquals( values.size(), nodeCount ); + assertEquals( values.size(), nodeCount ); } @Test @@ -315,7 +319,7 @@ public void shouldIgnoreWhitespaceAroundDecimalNumbers() throws Exception double expected = Double.parseDouble( name.trim() ); - Assert.assertEquals( 3, node.getAllProperties().size() ); + assertEquals( 3, node.getAllProperties().size() ); for ( String key : node.getPropertyKeys() ) { if ( key.equals( "name" ) ) @@ -331,7 +335,7 @@ public void shouldIgnoreWhitespaceAroundDecimalNumbers() throws Exception tx.success(); } - Assert.assertEquals( values.size(), nodeCount ); + assertEquals( values.size(), nodeCount ); } @Test @@ -372,12 +376,12 @@ public void shouldIgnoreWhitespaceAroundBooleans() throws Exception } else { - Assert.assertFalse( "Wrong value on " + name, (boolean) node.getProperty( "adult" ) ); + assertFalse( "Wrong value on " + name, (boolean) node.getProperty( "adult" ) ); } } long nodeCount = Iterables.count( dbRule.getAllNodes() ); - Assert.assertEquals( 10, nodeCount ); + assertEquals( 10, nodeCount ); tx.success(); } } @@ -412,7 +416,7 @@ public void shouldIgnoreWhitespaceInAndAroundIntegerArrays() throws Exception { nodeCount++; - Assert.assertEquals( 6, node.getAllProperties().size() ); + assertEquals( 6, node.getAllProperties().size() ); for ( String key : node.getPropertyKeys() ) { Object things = node.getProperty( key ); @@ -444,14 +448,14 @@ public void shouldIgnoreWhitespaceInAndAroundIntegerArrays() throws Exception break; } - Assert.assertEquals( expected, result ); + assertEquals( expected, result ); } } tx.success(); } - Assert.assertEquals( 1, nodeCount ); + assertEquals( 1, nodeCount ); } @Test @@ -478,7 +482,7 @@ public void shouldIgnoreWhitespaceInAndAroundDecimalArrays() throws Exception { nodeCount++; - Assert.assertEquals( 2, node.getAllProperties().size() ); + assertEquals( 2, node.getAllProperties().size() ); for ( String key : node.getPropertyKeys() ) { Object things = node.getProperty( key ); @@ -495,14 +499,14 @@ public void shouldIgnoreWhitespaceInAndAroundDecimalArrays() throws Exception break; } - Assert.assertEquals( expected, result ); + assertEquals( expected, result ); } } tx.success(); } - Assert.assertEquals( 1, nodeCount ); + assertEquals( 1, nodeCount ); } @Test @@ -528,20 +532,20 @@ public void shouldIgnoreWhitespaceInAndAroundBooleanArrays() throws Exception { nodeCount++; - Assert.assertEquals( 1, node.getAllProperties().size() ); + assertEquals( 1, node.getAllProperties().size() ); for ( String key : node.getPropertyKeys() ) { Object things = node.getProperty( key ); String result = Arrays.toString( (boolean[]) things ); - Assert.assertEquals( expected, result ); + assertEquals( expected, result ); } } tx.success(); } - Assert.assertEquals( 1, nodeCount ); + assertEquals( 1, nodeCount ); } @Test @@ -565,12 +569,12 @@ public void shouldFailIfHeaderHasLessColumnsThanData() throws Exception "--relationships", relationshipHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + relationshipData( false, config, nodeIds, TRUE, true ).getAbsolutePath() ); - Assert.fail( "Should have thrown exception" ); + fail( "Should have thrown exception" ); } catch ( InputException e ) { // THEN - Assert.assertFalse( suppressOutput.getErrorVoice().containsMessage( e.getClass().getName() ) ); + assertFalse( suppressOutput.getErrorVoice().containsMessage( e.getClass().getName() ) ); assertTrue( e.getMessage().contains( "Extra column not present in header on line" ) ); } } @@ -670,7 +674,7 @@ else if ( nodeHasLabels( node, secondLabels ) ) } else { - Assert.fail( node + " has neither set of labels, it has " + labelsOf( node ) ); + fail( node + " has neither set of labels, it has " + labelsOf( node ) ); } }, relationship -> @@ -685,13 +689,13 @@ else if ( relationship.isType( RelationshipType.withName( secondType ) ) ) } else { - Assert.fail( relationship + " didn't have either type, it has " + relationship.getType().name() ); + fail( relationship + " didn't have either type, it has " + relationship.getType().name() ); } } ); - Assert.assertEquals( NODE_COUNT / 2, numberOfNodesWithFirstSetOfLabels.intValue() ); - Assert.assertEquals( NODE_COUNT / 2, numberOfNodesWithSecondSetOfLabels.intValue() ); - Assert.assertEquals( RELATIONSHIP_COUNT / 2, numberOfRelationshipsWithFirstType.intValue() ); - Assert.assertEquals( RELATIONSHIP_COUNT / 2, numberOfRelationshipsWithSecondType.intValue() ); + assertEquals( NODE_COUNT / 2, numberOfNodesWithFirstSetOfLabels.intValue() ); + assertEquals( NODE_COUNT / 2, numberOfNodesWithSecondSetOfLabels.intValue() ); + assertEquals( RELATIONSHIP_COUNT / 2, numberOfRelationshipsWithFirstType.intValue() ); + assertEquals( RELATIONSHIP_COUNT / 2, numberOfRelationshipsWithSecondType.intValue() ); } private static String labelsOf( Node node ) @@ -738,9 +742,9 @@ public void shouldImportOnlyNodes() throws Exception { assertTrue( node.hasProperty( "name" ) ); nodeCount++; - Assert.assertFalse( node.hasRelationship() ); + assertFalse( node.hasRelationship() ); } - Assert.assertEquals( NODE_COUNT, nodeCount ); + assertEquals( NODE_COUNT, nodeCount ); tx.success(); } } @@ -778,9 +782,9 @@ public void shouldImportGroupsOfOverlappingIds() throws Exception { assertTrue( node.hasProperty( "name" ) ); nodeCount++; - Assert.assertEquals( 1, Iterables.count( node.getRelationships() ) ); + assertEquals( 1, Iterables.count( node.getRelationships() ) ); } - Assert.assertEquals( 6, nodeCount ); + assertEquals( 6, nodeCount ); tx.success(); } } @@ -843,7 +847,7 @@ public void shouldIncludeSourceInformationInNodeIdCollisionError() throws Except "--nodes", nodeHeaderFile.getAbsolutePath() + MULTI_FILE_DELIMITER + nodeData1.getAbsolutePath() + MULTI_FILE_DELIMITER + nodeData2.getAbsolutePath() ); - Assert.fail( "Should have failed with duplicate node IDs" ); + fail( "Should have failed with duplicate node IDs" ); } catch ( Exception e ) { @@ -882,7 +886,7 @@ public void shouldSkipDuplicateNodesIfToldTo() throws Exception assertTrue( id + ", " + foundNodesIds, foundNodesIds.add( id ) ); assertTrue( expectedNodeIds.contains( id ) ); } - Assert.assertEquals( expectedNodeIds, foundNodesIds ); + assertEquals( expectedNodeIds, foundNodesIds ); // also all nodes in the label index should exist for ( int i = 0; i < MAX_LABEL_ID; i++ ) @@ -895,7 +899,7 @@ public void shouldSkipDuplicateNodesIfToldTo() throws Exception Node node = nodesByLabel.next(); if ( !node.hasLabel( label ) ) { - Assert.fail( "Expected " + node + " to have label " + label.name() + ", but instead had " + + fail( "Expected " + node + " to have label " + label.name() + ", but instead had " + asList( node.getLabels() ) ); } } @@ -970,7 +974,7 @@ public void skipLoggingOfBadEntries() throws Exception "--relationships", relationshipData1.getAbsolutePath() + MULTI_FILE_DELIMITER + relationshipData2.getAbsolutePath() ); - Assert.assertFalse( badFile().exists() ); + assertFalse( badFile().exists() ); verifyRelationships( relationships ); } @@ -1000,7 +1004,7 @@ public void shouldFailIfTooManyBadRelationships() throws Exception "--bad", bad.getAbsolutePath(), "--bad-tolerance", "1", "--relationships", relationshipData.getAbsolutePath() ); - Assert.fail(); + fail(); } catch ( Exception e ) { @@ -1037,7 +1041,7 @@ public void shouldBeAbleToDisableSkippingOfBadRelationships() throws Exception "--skip-bad-relationships", "false", "--relationships", relationshipData1.getAbsolutePath() + MULTI_FILE_DELIMITER + relationshipData2.getAbsolutePath() ); - Assert.fail(); + fail(); } catch ( Exception e ) { @@ -1104,12 +1108,12 @@ public void shouldDisallowImportWithoutNodesInput() throws Exception "--into", dbRule.getStoreDirAbsolutePath(), "--relationships", relationshipData( true, config, nodeIds, TRUE, true ).getAbsolutePath() ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( IllegalArgumentException e ) { // THEN - Assert.assertThat( e.getMessage(), containsString( "No node input" ) ); + assertThat( e.getMessage(), containsString( "No node input" ) ); } } @@ -1142,10 +1146,10 @@ public void shouldBeAbleToImportAnonymousNodes() throws Exception } else { - Assert.assertNotNull( Iterators.single( Iterators.filter( nodeFilter( id ), allNodes.iterator() ) ) ); + assertNotNull( Iterators.single( Iterators.filter( nodeFilter( id ), allNodes.iterator() ) ) ); } } - Assert.assertEquals( anonymousCount, count( Iterators.filter( nodeFilter( "" ), allNodes.iterator() ) ) ); + assertEquals( anonymousCount, count( Iterators.filter( nodeFilter( "" ), allNodes.iterator() ) ) ); tx.success(); } } @@ -1162,7 +1166,7 @@ public void shouldDisallowMultilineFieldsByDefault() throws Exception importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--nodes", data.getAbsolutePath() ); - Assert.fail(); + fail(); } catch ( Exception e ) { @@ -1191,7 +1195,7 @@ public void shouldNotTrimStringsByDefault() throws Exception Node node = Iterators.single( allNodes ); allNodes.close(); - Assert.assertEquals( name, node.getProperty( "name" ) ); + assertEquals( name, node.getProperty( "name" ) ); tx.success(); } @@ -1295,7 +1299,7 @@ private void shouldPrintReferenceLinkAsPartOfErrorMessage( List nodeIds, "--skip-bad-relationships", "false", "--relationships", relationshipData( true, config, relationshipDataLines, TRUE, true ).getAbsolutePath() ); - Assert.fail( " Should fail during import." ); + fail( " Should fail during import." ); } catch ( Exception e ) { @@ -1332,7 +1336,7 @@ public void shouldAllowMultilineFieldsWhenEnabled() throws Exception Node node = Iterators.single( allNodes ); allNodes.close(); - Assert.assertEquals( "This is a line with\nnewlines in", node.getProperty( "name" ) ); + assertEquals( "This is a line with\nnewlines in", node.getProperty( "name" ) ); tx.success(); } @@ -1353,7 +1357,7 @@ public void shouldSkipEmptyFiles() throws Exception try ( Transaction tx = graphDatabaseService.beginTx() ) { ResourceIterator allNodes = graphDatabaseService.getAllNodes().iterator(); - Assert.assertFalse( "Expected database to be empty", allNodes.hasNext() ); + assertFalse( "Expected database to be empty", allNodes.hasNext() ); tx.success(); } } @@ -1377,9 +1381,9 @@ public void shouldIgnoreEmptyQuotedStringsIfConfiguredTo() throws Exception try ( Transaction tx = db.beginTx() ) { Node node = Iterables.single( db.getAllNodes() ); - Assert.assertFalse( node.hasProperty( "one" ) ); - Assert.assertFalse( node.hasProperty( "two" ) ); - Assert.assertEquals( "value", node.getProperty( "three" ) ); + assertFalse( node.hasProperty( "one" ) ); + assertFalse( node.hasProperty( "two" ) ); + assertEquals( "value", node.getProperty( "three" ) ); tx.success(); } } @@ -1399,7 +1403,7 @@ public void shouldPrintUserFriendlyMessageAboutUnsupportedMultilineFields() thro "--into", dbRule.getStoreDirAbsolutePath(), "--nodes", data.getAbsolutePath(), "--multiline-fields", "false" ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( InputException e ) { @@ -1477,12 +1481,12 @@ public void shouldReportBadDelimiterConfiguration() throws Exception "--array-delimiter", String.valueOf( config.arrayDelimiter() ), "--nodes", nodeData( true, config, nodeIds, TRUE ).getAbsolutePath(), "--relationships", relationshipData( true, config, nodeIds, TRUE, true ).getAbsolutePath() ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( IllegalArgumentException e ) { // THEN - Assert.assertThat( e.getMessage(), containsString( "bogus" ) ); + assertThat( e.getMessage(), containsString( "bogus" ) ); } } @@ -1499,12 +1503,12 @@ public void shouldFailAndReportStartingLineForUnbalancedQuoteInMiddle() throws E "--into", dbRule.getStoreDirAbsolutePath(), "--nodes", nodeDataWithMissingQuote( 2 * unbalancedStartLine, unbalancedStartLine ) .getAbsolutePath() ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( InputException e ) { // THEN - Assert.assertThat( e.getMessage(), containsString( String.format( "Multi-line fields are illegal", unbalancedStartLine ) ) ); + assertThat( e.getMessage(), containsString( String.format( "Multi-line fields are illegal", unbalancedStartLine ) ) ); } } @@ -1553,12 +1557,12 @@ public void shouldFailAndReportStartingLineForUnbalancedQuoteAtEnd() throws Exce importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--nodes", nodeDataWithMissingQuote( unbalancedStartLine, unbalancedStartLine ).getAbsolutePath() ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( InputException e ) { // THEN - Assert.assertThat( e.getMessage(), containsString( String.format( "Multi-line fields" ) ) ); + assertThat( e.getMessage(), containsString( String.format( "Multi-line fields" ) ) ); } } @@ -1582,8 +1586,8 @@ public void shouldBeEquivalentToUseRawAsciiOrCharacterAsQuoteConfiguration1() th "--quote", weirdStringDelimiter ); // THEN - Assert.assertEquals( "~", "" + weirdDelimiter ); - Assert.assertEquals( "~".charAt( 0 ), weirdDelimiter ); + assertEquals( "~", "" + weirdDelimiter ); + assertEquals( "~".charAt( 0 ), weirdDelimiter ); Set names = asSet( "Weird", name2 ); GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); @@ -1613,7 +1617,7 @@ public void shouldFailOnUnbalancedQuoteWithMultilinesEnabled() throws Exception "--multiline-fields", "true", "--nodes", nodeDataWithMissingQuote( 2 * unbalancedStartLine, unbalancedStartLine ).getAbsolutePath() ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( InputException e ) { // THEN OK @@ -1664,8 +1668,8 @@ public void shouldBeEquivalentToUseRawAsciiOrCharacterAsQuoteConfiguration2() th "--quote", weirdStringDelimiter ); // THEN - Assert.assertEquals( weirdStringDelimiter, "" + weirdDelimiter ); - Assert.assertEquals( weirdStringDelimiter.charAt( 0 ), weirdDelimiter ); + assertEquals( weirdStringDelimiter, "" + weirdDelimiter ); + assertEquals( weirdStringDelimiter.charAt( 0 ), weirdDelimiter ); Set names = asSet( "Weird", name2 ); GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); @@ -1703,8 +1707,8 @@ public void shouldRespectDbConfig() throws Exception NeoStores stores = dbRule.getGraphDatabaseAPI().getDependencyResolver() .resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); int headerSize = Standard.LATEST_RECORD_FORMATS.dynamic().getRecordHeaderSize(); - Assert.assertEquals( arrayBlockSize + headerSize, stores.getPropertyStore().getArrayStore().getRecordSize() ); - Assert.assertEquals( stringBlockSize + headerSize, stores.getPropertyStore().getStringStore().getRecordSize() ); + assertEquals( arrayBlockSize + headerSize, stores.getPropertyStore().getArrayStore().getRecordSize() ); + assertEquals( stringBlockSize + headerSize, stores.getPropertyStore().getStringStore().getRecordSize() ); } @Test @@ -1729,8 +1733,8 @@ public void useProvidedAdditionalConfig() throws Exception NeoStores stores = dbRule.getGraphDatabaseAPI().getDependencyResolver() .resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); int headerSize = Standard.LATEST_RECORD_FORMATS.dynamic().getRecordHeaderSize(); - Assert.assertEquals( arrayBlockSize + headerSize, stores.getPropertyStore().getArrayStore().getRecordSize() ); - Assert.assertEquals( stringBlockSize + headerSize, stores.getPropertyStore().getStringStore().getRecordSize() ); + assertEquals( arrayBlockSize + headerSize, stores.getPropertyStore().getArrayStore().getRecordSize() ); + assertEquals( stringBlockSize + headerSize, stores.getPropertyStore().getStringStore().getRecordSize() ); } @Test @@ -1758,8 +1762,8 @@ public void combineProvidedDbAndAdditionalConfig() throws Exception NeoStores stores = dbRule.getGraphDatabaseAPI().getDependencyResolver() .resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); int headerSize = Standard.LATEST_RECORD_FORMATS.dynamic().getRecordHeaderSize(); - Assert.assertEquals( arrayBlockSize + headerSize, stores.getPropertyStore().getArrayStore().getRecordSize() ); - Assert.assertEquals( stringBlockSize + headerSize, stores.getPropertyStore().getStringStore().getRecordSize() ); + assertEquals( arrayBlockSize + headerSize, stores.getPropertyStore().getArrayStore().getRecordSize() ); + assertEquals( stringBlockSize + headerSize, stores.getPropertyStore().getStringStore().getRecordSize() ); } @Test @@ -1780,7 +1784,7 @@ public void shouldPrintStackTraceOnInputExceptionIfToldTo() throws Exception .getAbsolutePath(), "--stacktrace" ); - Assert.fail( "Should have thrown exception" ); + fail( "Should have thrown exception" ); } catch ( InputException e ) { @@ -1811,7 +1815,7 @@ public void shouldDisableLegacyStyleQuotingIfToldTo() throws Exception GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); try ( Transaction tx = db.beginTx() ) { - Assert.assertNotNull( db.findNode( label( labelName ), "name", "abc\"def\\\"ghi" ) ); + assertNotNull( db.findNode( label( labelName ), "name", "abc\"def\\\"ghi" ) ); } } @@ -1831,12 +1835,12 @@ public void shouldRespectBufferSizeSetting() throws Exception "--nodes", data( lines.toArray( new String[lines.size()] ) ).getAbsolutePath(), "--read-buffer-size", "1k" ); - Assert.fail( "Should've failed" ); + fail( "Should've failed" ); } catch ( IllegalStateException e ) { // THEN good - Assert.assertThat( e.getMessage(), containsString( "input data" ) ); + assertThat( e.getMessage(), containsString( "input data" ) ); } } @@ -1864,12 +1868,12 @@ public void shouldFailOnInvalidMaxMemoryPercentageSetting() throws Exception // WHEN importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--nodes", nodeData( true, Configuration.COMMAS, nodeIds, TRUE ).getAbsolutePath(), "--max-memory", "110%" ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( IllegalArgumentException e ) { // THEN good - Assert.assertThat( e.getMessage(), containsString( "percent" ) ); + assertThat( e.getMessage(), containsString( "percent" ) ); } } @@ -1911,7 +1915,7 @@ public void shouldTreatRelationshipWithMissingStartOrEndIdOrTypeAsBadRelationshi "--relationships", relationshipData.getAbsolutePath() ); String badContents = FileUtils.readTextFile( bad, Charset.defaultCharset() ); - Assert.assertEquals( badContents, 3, occurencesOf( badContents, "is missing data" ) ); + assertEquals( badContents, 3, occurencesOf( badContents, "is missing data" ) ); } @Test @@ -1930,7 +1934,7 @@ public void shouldKeepStoreFilesAfterFailedImport() throws Exception "--into", storeDir, "--nodes", nodeHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + nodeData( false, config, nodeIds, TRUE, Charset.defaultCharset(), extraColumns ).getAbsolutePath() ); - Assert.fail( "Should have thrown exception" ); + fail( "Should have thrown exception" ); } catch ( InputException e ) { @@ -1989,13 +1993,13 @@ public void shouldFailIfSupplyingBothFileArgumentAndAnyOtherArgument() throws Ex { // when importTool( "-f", argumentFile.getAbsolutePath(), "--into", dbRule.getStoreDirAbsolutePath() ); - Assert.fail( "Should have failed" ); + fail( "Should have failed" ); } catch ( IllegalArgumentException e ) { // then good - Assert.assertThat( e.getMessage(), containsString( "in addition to" ) ); - Assert.assertThat( e.getMessage(), containsString( ImportTool.Options.FILE.argument() ) ); + assertThat( e.getMessage(), containsString( "in addition to" ) ); + assertThat( e.getMessage(), containsString( ImportTool.Options.FILE.argument() ) ); } } @@ -2008,7 +2012,7 @@ private void assertContains( List errorLines, String string ) return; } } - Assert.fail( "Expected error lines " + join( errorLines.toArray( new String[errorLines.size()] ), format( "%n" ) ) + + fail( "Expected error lines " + join( errorLines.toArray( new String[errorLines.size()] ), format( "%n" ) ) + " to have at least one line containing the string '" + string + "'" ); } @@ -2087,15 +2091,6 @@ private Predicate nodeFilter( final String id ) return node -> node.getProperty( "id", "" ).equals( id ); } - private void assertNodeHasLabels( Node node, String[] names ) - { - for ( String name : names ) - { - assertTrue( node + " didn't have label " + name + ", it had labels " + node.getLabels(), - node.hasLabel( label( name ) ) ); - } - } - private void verifyData() { verifyData( Validators.emptyValidator(), Validators.emptyValidator() ); @@ -2123,14 +2118,14 @@ private void verifyData( int expectedNodeCount, int expectedRelationshipCount, nodeAdditionalValidation.validate( node ); nodeCount++; } - Assert.assertEquals( expectedNodeCount, nodeCount ); + assertEquals( expectedNodeCount, nodeCount ); for ( Relationship relationship : db.getAllRelationships() ) { assertTrue( relationship.hasProperty( "created" ) ); relationshipAdditionalValidation.validate( relationship ); relationshipCount++; } - Assert.assertEquals( expectedRelationshipCount, relationshipCount ); + assertEquals( expectedRelationshipCount, relationshipCount ); tx.success(); } } @@ -2150,7 +2145,7 @@ private void verifyRelationships( List relationships ) // OK this is a relationship refering to a missing node, skip it continue; } - Assert.assertNotNull( relationship.toString(), findRelationship( startNode, endNode, relationship ) ); + assertNotNull( relationship.toString(), findRelationship( startNode, endNode, relationship ) ); } tx.success(); } diff --git a/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/TestLuceneIndex.java b/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/TestLuceneIndex.java index 29ed63897bbbe..4b9de116b3eb9 100644 --- a/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/TestLuceneIndex.java +++ b/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/TestLuceneIndex.java @@ -33,7 +33,6 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.similarities.DefaultSimilarity; import org.hamcrest.CoreMatchers; -import org.junit.Assert; import org.junit.Test; import java.util.HashMap; @@ -1944,12 +1943,12 @@ public void getOrCreateMultiThreaded() throws Exception t2.beginTransaction(); Node node = t2.getOrCreate( key, value, 0 ).get(); assertNotNull( node ); - Assert.assertEquals( 0, t2.getProperty( node, key ) ); + assertEquals( 0, t2.getProperty( node, key ) ); Future futurePut = t1.getOrCreate( key, value, 1 ); t1.waitUntilWaiting(); t2.commit(); assertEquals( node, futurePut.get() ); - Assert.assertEquals( 0, t1.getProperty( node, key ) ); + assertEquals( 0, t1.getProperty( node, key ) ); t1.commit(); assertEquals( node, index.get( key, value ).getSingle() ); diff --git a/community/community-it/index-it/src/test/java/org/neo4j/kernel/impl/index/schema/RecoverIndexDropIT.java b/community/community-it/index-it/src/test/java/org/neo4j/kernel/impl/index/schema/RecoverIndexDropIT.java index 2b9de6900eeff..146cad3c1e39c 100644 --- a/community/community-it/index-it/src/test/java/org/neo4j/kernel/impl/index/schema/RecoverIndexDropIT.java +++ b/community/community-it/index-it/src/test/java/org/neo4j/kernel/impl/index/schema/RecoverIndexDropIT.java @@ -46,13 +46,13 @@ import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.kernel.recovery.RecoveryMonitor; import org.neo4j.test.TestGraphDatabaseFactory; -import org.neo4j.test.TestLabels; import org.neo4j.test.rule.TestDirectory; import org.neo4j.test.rule.fs.DefaultFileSystemRule; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.neo4j.helpers.collection.Iterables.count; +import static org.neo4j.test.TestLabels.LABEL_ONE; /** * Issue came up when observing that recovering an INDEX DROP command didn't actually call {@link IndexProxy#drop()}, @@ -111,7 +111,7 @@ private IndexDefinition createIndex( GraphDatabaseService db ) { try ( Transaction tx = db.beginTx() ) { - IndexDefinition index = db.schema().indexFor( TestLabels.LABEL_ONE ).on( KEY ).create(); + IndexDefinition index = db.schema().indexFor( LABEL_ONE ).on( KEY ).create(); tx.success(); return index; } diff --git a/community/community-it/index-it/src/test/java/schema/DynamicIndexStoreViewIT.java b/community/community-it/index-it/src/test/java/schema/DynamicIndexStoreViewIT.java index 2480cc9236174..a821ea0aed0b4 100644 --- a/community/community-it/index-it/src/test/java/schema/DynamicIndexStoreViewIT.java +++ b/community/community-it/index-it/src/test/java/schema/DynamicIndexStoreViewIT.java @@ -39,12 +39,13 @@ import org.neo4j.helpers.progress.ProgressMonitorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.logging.FormattedLogProvider; -import org.neo4j.test.DoubleLatch; import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.rule.SuppressOutput; import org.neo4j.test.rule.TestDirectory; import org.neo4j.values.storable.RandomValues; +import static org.neo4j.test.DoubleLatch.awaitLatch; + public class DynamicIndexStoreViewIT { private final SuppressOutput suppressOutput = SuppressOutput.suppressAll(); @@ -137,7 +138,7 @@ private class Populator implements Runnable public void run() { RandomValues randomValues = RandomValues.create(); - DoubleLatch.awaitLatch( startSignal ); + awaitLatch( startSignal ); while ( !endSignal.get() ) { try ( Transaction transaction = databaseService.beginTx() ) diff --git a/community/community-it/index-it/src/test/java/schema/MultipleIndexPopulationStressIT.java b/community/community-it/index-it/src/test/java/schema/MultipleIndexPopulationStressIT.java index 4c546c61cf419..13ffbf2885ad0 100644 --- a/community/community-it/index-it/src/test/java/schema/MultipleIndexPopulationStressIT.java +++ b/community/community-it/index-it/src/test/java/schema/MultipleIndexPopulationStressIT.java @@ -79,6 +79,7 @@ import static org.neo4j.helpers.progress.ProgressMonitorFactory.NONE; import static org.neo4j.unsafe.impl.batchimport.AdditionalInitialIds.EMPTY; import static org.neo4j.unsafe.impl.batchimport.Configuration.DEFAULT; +import static org.neo4j.unsafe.impl.batchimport.GeneratingInputIterator.EMPTY_ITERABLE; import static org.neo4j.unsafe.impl.batchimport.ImportLogic.NO_MONITOR; import static org.neo4j.unsafe.impl.batchimport.input.Inputs.knownEstimates; @@ -327,7 +328,7 @@ private class RandomDataInput implements Input, AutoCloseable @Override public InputIterable relationships() { - return GeneratingInputIterator.EMPTY_ITERABLE; + return EMPTY_ITERABLE; } @Override diff --git a/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java b/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java index c0681733ac1a4..a2146c81fe51d 100644 --- a/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java +++ b/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java @@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory; +import org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.Dependencies; import org.neo4j.graphdb.facade.embedded.EmbeddedGraphDatabase; import org.neo4j.graphdb.factory.module.CommunityEditionModule; import org.neo4j.graphdb.factory.module.PlatformModule; @@ -123,26 +124,26 @@ public ImpermanentGraphDatabase( File storeDir, Map params, this( storeDir, params, getDependencies( kernelExtensions ) ); } - private static GraphDatabaseFacadeFactory.Dependencies getDependencies( Iterable> kernelExtensions ) + private static Dependencies getDependencies( Iterable> kernelExtensions ) { return newDependencies().kernelExtensions( kernelExtensions ); } - public ImpermanentGraphDatabase( File storeDir, Map params, GraphDatabaseFacadeFactory.Dependencies dependencies ) + public ImpermanentGraphDatabase( File storeDir, Map params, Dependencies dependencies ) { super( storeDir, params, dependencies ); trackUnclosedUse( storeDir ); } public ImpermanentGraphDatabase( File storeDir, Config config, - GraphDatabaseFacadeFactory.Dependencies dependencies ) + Dependencies dependencies ) { super( storeDir, config, dependencies ); trackUnclosedUse( storeDir ); } @Override - protected void create( File storeDir, Map params, GraphDatabaseFacadeFactory.Dependencies dependencies ) + protected void create( File storeDir, Map params, Dependencies dependencies ) { new GraphDatabaseFacadeFactory( DatabaseInfo.COMMUNITY, CommunityEditionModule::new ) { @@ -190,7 +191,7 @@ private static Config withForcedInMemoryConfiguration( Config config ) protected static class ImpermanentPlatformModule extends PlatformModule { public ImpermanentPlatformModule( File storeDir, Config config, DatabaseInfo databaseInfo, - GraphDatabaseFacadeFactory.Dependencies dependencies, + Dependencies dependencies, GraphDatabaseFacade graphDatabaseFacade ) { super( storeDir, withForcedInMemoryConfiguration(config), databaseInfo, dependencies, graphDatabaseFacade ); diff --git a/community/community-it/kernel-it/src/test/java/counts/RebuildCountsTest.java b/community/community-it/kernel-it/src/test/java/counts/RebuildCountsTest.java index 4c7eb7daea2f4..e29cd5e0b49a1 100644 --- a/community/community-it/kernel-it/src/test/java/counts/RebuildCountsTest.java +++ b/community/community-it/kernel-it/src/test/java/counts/RebuildCountsTest.java @@ -53,6 +53,8 @@ import static org.junit.Assert.assertTrue; import static org.neo4j.graphdb.Label.label; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.index_background_sampling_enabled; +import static org.neo4j.logging.AssertableLogProvider.LogMatcherBuilder; +import static org.neo4j.logging.AssertableLogProvider.inLog; import static org.neo4j.register.Registers.newDoubleLongRegister; public class RebuildCountsTest @@ -75,7 +77,7 @@ public void shouldRebuildMissingCountsStoreOnStart() throws IOException assertEquals( HUMANS, tracker.nodeCount( labelId( HUMAN ), newDoubleLongRegister() ).readSecond() ); // and also - AssertableLogProvider.LogMatcherBuilder matcherBuilder = AssertableLogProvider.inLog( MetaDataStore.class ); + LogMatcherBuilder matcherBuilder = inLog( MetaDataStore.class ); internalLogProvider.assertAtLeastOnce( matcherBuilder.warn( "Missing counts store, rebuilding it." ) ); internalLogProvider.assertAtLeastOnce( matcherBuilder.warn( "Counts store rebuild completed." ) ); } @@ -100,7 +102,7 @@ public void shouldRebuildMissingCountsStoreAfterRecovery() throws IOException assertEquals( 0, tracker.nodeCount( labelId( HUMAN ), newDoubleLongRegister() ).readSecond() ); // and also - AssertableLogProvider.LogMatcherBuilder matcherBuilder = AssertableLogProvider.inLog( MetaDataStore.class ); + LogMatcherBuilder matcherBuilder = inLog( MetaDataStore.class ); internalLogProvider.assertAtLeastOnce( matcherBuilder.warn( "Missing counts store, rebuilding it." ) ); internalLogProvider.assertAtLeastOnce( matcherBuilder.warn( "Counts store rebuild completed." ) ); } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/LabelsAcceptanceTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/LabelsAcceptanceTest.java index 67c4778602198..aa67e25ba1dea 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/LabelsAcceptanceTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/LabelsAcceptanceTest.java @@ -19,7 +19,6 @@ */ package org.neo4j.graphdb; -import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; @@ -63,12 +62,12 @@ import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.TestGraphDatabaseFactoryState; import org.neo4j.test.impl.EphemeralIdGenerator; -import org.neo4j.test.mockito.matcher.Neo4jMatchers; import org.neo4j.test.rule.ImpermanentDatabaseRule; import org.neo4j.test.rule.TestDirectory; import static java.util.stream.Collectors.toSet; import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; @@ -79,6 +78,10 @@ import static org.neo4j.helpers.collection.Iterables.map; import static org.neo4j.helpers.collection.Iterators.asSet; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasLabel; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasLabels; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasNoLabels; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasNoNodes; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasNodes; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.inTx; public class LabelsAcceptanceTest @@ -238,7 +241,7 @@ public void removingCommittedLabel() } // Then - assertThat( myNode, Matchers.not( inTx( graphDatabase, hasLabel( label ) ) ) ); + assertThat( myNode, not( inTx( graphDatabase, hasLabel( label ) ) ) ); } @Test @@ -258,7 +261,7 @@ public void createNodeWithLabels() // THEN Set names = Stream.of( Labels.values() ).map( Labels::name ).collect( toSet() ); - assertThat( node, inTx( db, Neo4jMatchers.hasLabels( names ) ) ); + assertThat( node, inTx( db, hasLabels( names ) ) ); } @Test @@ -278,7 +281,7 @@ public void removingNonExistentLabel() } // THEN - assertThat( myNode, Matchers.not( inTx( beansAPI, hasLabel( label ) ) ) ); + assertThat( myNode, not( inTx( beansAPI, hasLabel( label ) ) ) ); } @Test @@ -298,7 +301,7 @@ public void removingExistingLabelFromUnlabeledNode() } // THEN - assertThat( myNode, Matchers.not( inTx( beansAPI, hasLabel( label ) ) ) ); + assertThat( myNode, not( inTx( beansAPI, hasLabel( label ) ) ) ); } @Test @@ -340,7 +343,7 @@ public void shouldBeAbleToListLabelsForANode() tx.success(); } - assertThat( node, inTx( beansAPI, Neo4jMatchers.hasLabels( expected ) ) ); + assertThat( node, inTx( beansAPI, hasLabels( expected ) ) ); } @Test @@ -351,7 +354,7 @@ public void shouldReturnEmptyListIfNoLabels() Node node = createNode( beansAPI ); // WHEN THEN - assertThat( node, inTx( beansAPI, Neo4jMatchers.hasNoLabels() ) ); + assertThat( node, inTx( beansAPI, hasNoLabels() ) ); } @Test @@ -370,8 +373,8 @@ public void getNodesWithLabelCommitted() } // THEN - assertThat( beansAPI, inTx( beansAPI, Neo4jMatchers.hasNodes( Labels.MY_LABEL, node ) ) ); - assertThat( beansAPI, inTx( beansAPI, Neo4jMatchers.hasNoNodes( Labels.MY_OTHER_LABEL ) ) ); + assertThat( beansAPI, inTx( beansAPI, hasNodes( Labels.MY_LABEL, node ) ) ); + assertThat( beansAPI, inTx( beansAPI, hasNoNodes( Labels.MY_OTHER_LABEL ) ) ); } @Test diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintCreatorTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintCreatorTest.java index 879f929cb409a..f19a1e4b29d48 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintCreatorTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintCreatorTest.java @@ -31,13 +31,13 @@ public class MandatoryTransactionsForConstraintCreatorTest @Test public void shouldRequireTransactionsWhenCallingMethodsConstraintCreators() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ConstraintCreatorFacadeMethods.ALL_CONSTRAINT_CREATOR_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_CONSTRAINT_CREATOR_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsConstraintCreators() { - assertFacadeMethodsThrowAfterTerminate( ConstraintCreatorFacadeMethods.ALL_CONSTRAINT_CREATOR_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_CONSTRAINT_CREATOR_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintDefinitionTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintDefinitionTest.java index 6915a686ad9d0..6f1ef67ca030b 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintDefinitionTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForConstraintDefinitionTest.java @@ -32,13 +32,13 @@ public class MandatoryTransactionsForConstraintDefinitionTest @Test public void shouldRequireTransactionsWhenCallingMethodsOnIndexDefinitions() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ConstraintDefinitionFacadeMethods.ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnIndexDefinitions() { - assertFacadeMethodsThrowAfterTerminate( ConstraintDefinitionFacadeMethods.ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForGraphDatabaseServiceTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForGraphDatabaseServiceTest.java index a5d158d6c31a5..7a7a8b59c5d10 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForGraphDatabaseServiceTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForGraphDatabaseServiceTest.java @@ -29,13 +29,13 @@ public class MandatoryTransactionsForGraphDatabaseServiceTest extends @Test public void shouldRequireTransactionsWhenCallingMethodsOnGraphDatabaseService() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), GraphDatabaseServiceFacadeMethods.ALL_NON_TRANSACTIONAL_GRAPH_DATABASE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_NON_TRANSACTIONAL_GRAPH_DATABASE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnGraphDatabaseService() { - assertFacadeMethodsThrowAfterTerminate( GraphDatabaseServiceFacadeMethods.ALL_NON_TRANSACTIONAL_GRAPH_DATABASE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_NON_TRANSACTIONAL_GRAPH_DATABASE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexCreatorTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexCreatorTest.java index 13a75a185c8cf..1231dd6ee3f60 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexCreatorTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexCreatorTest.java @@ -31,13 +31,13 @@ public class MandatoryTransactionsForIndexCreatorTest @Test public void shouldRequireTransactionsWhenCallingMethodsOnIndexCreators() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), IndexCreatorFacadeMethods.ALL_INDEX_CREATOR_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_INDEX_CREATOR_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnIndexCreators() { - assertFacadeMethodsThrowAfterTerminate( IndexCreatorFacadeMethods.ALL_INDEX_CREATOR_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_INDEX_CREATOR_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexDefinitionTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexDefinitionTest.java index 74f5d410865df..4f5219a5ffebe 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexDefinitionTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexDefinitionTest.java @@ -31,13 +31,13 @@ public class MandatoryTransactionsForIndexDefinitionTest @Test public void shouldRequireTransactionsWhenCallingMethodsOnIndexDefinitions() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), IndexDefinitionFacadeMethods.ALL_INDEX_DEFINITION_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_INDEX_DEFINITION_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnIndexDefinitions() { - assertFacadeMethodsThrowAfterTerminate( IndexDefinitionFacadeMethods.ALL_INDEX_DEFINITION_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_INDEX_DEFINITION_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexManagerFacadeTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexManagerFacadeTest.java index 2b1e3c727e89f..f225a1eb5d537 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexManagerFacadeTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForIndexManagerFacadeTest.java @@ -30,13 +30,13 @@ public class MandatoryTransactionsForIndexManagerFacadeTest extends AbstractMand @Test public void shouldRequireTransactionsWhenCallingMethodsOnIndexManagerFacade() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), IndexManagerFacadeMethods.ALL_INDEX_MANAGER_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_INDEX_MANAGER_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnIndexManagerFacade() { - assertFacadeMethodsThrowAfterTerminate( IndexManagerFacadeMethods.ALL_INDEX_MANAGER_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_INDEX_MANAGER_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForNodeTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForNodeTest.java index 75e143d0a396e..0571be4900732 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForNodeTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForNodeTest.java @@ -28,13 +28,13 @@ public class MandatoryTransactionsForNodeTest extends AbstractMandatoryTransacti @Test public void shouldRequireTransactionsWhenCallingMethodsOnNode() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), NodeFacadeMethods.ALL_NODE_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_NODE_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnNode() { - assertFacadeMethodsThrowAfterTerminate( NodeFacadeMethods.ALL_NODE_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_NODE_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForRelationshipTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForRelationshipTest.java index be5484e5f3f49..c451940fb4a4a 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForRelationshipTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForRelationshipTest.java @@ -29,13 +29,13 @@ public class MandatoryTransactionsForRelationshipTest extends AbstractMandatoryT @Test public void shouldRequireTransactionsWhenCallingMethodsOnRelationshipFacade() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), RelationshipFacadeMethods.ALL_RELATIONSHIP_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_RELATIONSHIP_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnRelationshipFacade() { - assertFacadeMethodsThrowAfterTerminate( RelationshipFacadeMethods.ALL_RELATIONSHIP_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_RELATIONSHIP_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForSchemaTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForSchemaTest.java index 653a1ba82a55a..0679f5d19972b 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForSchemaTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForSchemaTest.java @@ -30,13 +30,13 @@ public class MandatoryTransactionsForSchemaTest extends AbstractMandatoryTransac @Test public void shouldRequireTransactionsWhenCallingMethodsOnSchema() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), SchemaFacadeMethods.ALL_SCHEMA_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_SCHEMA_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnSchema() { - assertFacadeMethodsThrowAfterTerminate( SchemaFacadeMethods.ALL_SCHEMA_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_SCHEMA_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForUniquenessConstraintDefinitionTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForUniquenessConstraintDefinitionTest.java index e07e7ef46be21..0e5b8fcce5bd5 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForUniquenessConstraintDefinitionTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/MandatoryTransactionsForUniquenessConstraintDefinitionTest.java @@ -31,13 +31,13 @@ public class MandatoryTransactionsForUniquenessConstraintDefinitionTest @Test public void shouldRequireTransactionsWhenCallingMethodsOnUniquenessConstraintDefinitions() { - assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ConstraintDefinitionFacadeMethods.ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); + assertFacadeMethodsThrowNotInTransaction( obtainEntity(), ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); } @Test public void shouldTerminateWhenCallingMethodsOnUniquenessConstraintDefinitions() { - assertFacadeMethodsThrowAfterTerminate( ConstraintDefinitionFacadeMethods.ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); + assertFacadeMethodsThrowAfterTerminate( ALL_CONSTRAINT_DEFINITION_FACADE_METHODS ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/SchemaAcceptanceTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/SchemaAcceptanceTest.java index 6424ef66ceb8f..72f6960642b3a 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/SchemaAcceptanceTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/SchemaAcceptanceTest.java @@ -19,8 +19,6 @@ */ package org.neo4j.graphdb; -import org.hamcrest.MatcherAssert; -import org.hamcrest.core.IsNot; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -32,7 +30,6 @@ import org.neo4j.graphdb.schema.IndexDefinition; import org.neo4j.graphdb.schema.Schema; import org.neo4j.helpers.collection.Iterables; -import org.neo4j.test.mockito.matcher.Neo4jMatchers; import org.neo4j.test.rule.ImpermanentDatabaseRule; import static org.hamcrest.CoreMatchers.containsString; @@ -44,9 +41,14 @@ import static org.junit.Assert.fail; import static org.neo4j.helpers.collection.Iterables.count; import static org.neo4j.helpers.collection.Iterators.asSet; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.contains; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.containsOnly; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.createIndex; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.findNodesByLabelAndProperty; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.getConstraints; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.getIndexes; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.isEmpty; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.waitForIndex; public class SchemaAcceptanceTest { @@ -77,7 +79,7 @@ public void addingAnIndexingRuleShouldSucceed() IndexDefinition index = createIndex( db, label, propertyKey ); // THEN - MatcherAssert.assertThat( getIndexes( db, label ), containsOnly( index ) ); + assertThat( getIndexes( db, label ), containsOnly( index ) ); } @Test @@ -87,7 +89,7 @@ public void addingACompositeIndexingRuleShouldSucceed() IndexDefinition index = createIndex( db, label, propertyKey, secondPropertyKey ); // THEN - MatcherAssert.assertThat( getIndexes( db, label ), containsOnly( index ) ); + assertThat( getIndexes( db, label ), containsOnly( index ) ); } @Test @@ -108,10 +110,10 @@ public void addingAnIndexingRuleInNestedTxShouldSucceed() index = indexDef; tx.success(); } - Neo4jMatchers.waitForIndex( db, indexDef ); + waitForIndex( db, indexDef ); // THEN - MatcherAssert.assertThat( getIndexes( db, label ), containsOnly( index ) ); + assertThat( getIndexes( db, label ), containsOnly( index ) ); } @Test @@ -193,7 +195,7 @@ public void droppingExistingIndexRuleShouldSucceed() dropIndex( index ); // THEN - MatcherAssert.assertThat( getIndexes( db, label ), Neo4jMatchers.isEmpty() ); + assertThat( getIndexes( db, label ), isEmpty() ); } @Test @@ -219,7 +221,7 @@ public void droppingAnUnexistingIndexShouldGiveHelpfulExceptionInSameTransaction } // THEN - assertThat( "Index should have been deleted", getIndexes( db, label ), IsNot.not( Neo4jMatchers.contains( index ) ) ); + assertThat( "Index should have been deleted", getIndexes( db, label ), not( contains( index ) ) ); } @Test @@ -241,7 +243,7 @@ public void droppingAnUnexistingIndexShouldGiveHelpfulExceptionInSeparateTransac } // THEN - assertThat( "Index should have been deleted", getIndexes( db, label ), IsNot.not( Neo4jMatchers.contains( index ) ) ); + assertThat( "Index should have been deleted", getIndexes( db, label ), not( contains( index ) ) ); } @Test @@ -272,7 +274,7 @@ public void awaitingAllIndexesComingOnlineWorks() createIndex( db, label, "other_property" ); // PASS - Neo4jMatchers.waitForIndex( db, index ); + waitForIndex( db, index ); try ( Transaction tx = db.beginTx() ) { db.schema().awaitIndexesOnline( 1L, TimeUnit.MINUTES ); @@ -290,10 +292,10 @@ public void shouldPopulateIndex() // create an index IndexDefinition index = createIndex( db, label, propertyKey ); - Neo4jMatchers.waitForIndex( db, index ); + waitForIndex( db, index ); // THEN - MatcherAssert.assertThat( Neo4jMatchers.findNodesByLabelAndProperty( label, propertyKey, "Neo", db ), containsOnly( node ) ); + assertThat( findNodesByLabelAndProperty( label, propertyKey, "Neo", db ), containsOnly( node ) ); } @Test @@ -304,18 +306,18 @@ public void shouldRecreateDroppedIndex() // create an index IndexDefinition index = createIndex( db, label, propertyKey ); - Neo4jMatchers.waitForIndex( db, index ); + waitForIndex( db, index ); // delete the index right away dropIndex( index ); // WHEN recreating that index createIndex( db, label, propertyKey ); - Neo4jMatchers.waitForIndex( db, index ); + waitForIndex( db, index ); // THEN it should exist and be usable - MatcherAssert.assertThat( getIndexes( db, label ), Neo4jMatchers.contains( index ) ); - MatcherAssert.assertThat( Neo4jMatchers.findNodesByLabelAndProperty( label, propertyKey, "Neo", db ), containsOnly( node ) ); + assertThat( getIndexes( db, label ), contains( index ) ); + assertThat( findNodesByLabelAndProperty( label, propertyKey, "Neo", db ), containsOnly( node ) ); } @Test @@ -343,7 +345,7 @@ public void shouldListAddedConstraintsByLabel() createUniquenessConstraint( Labels.MY_OTHER_LABEL, propertyKey ); // WHEN THEN - MatcherAssert.assertThat( Neo4jMatchers.getConstraints( db, label ), containsOnly( constraint1 ) ); + assertThat( getConstraints( db, label ), containsOnly( constraint1 ) ); } @Test @@ -354,7 +356,7 @@ public void shouldListAddedConstraints() ConstraintDefinition constraint2 = createUniquenessConstraint( Labels.MY_OTHER_LABEL, propertyKey ); // WHEN THEN - MatcherAssert.assertThat( Neo4jMatchers.getConstraints( db ), containsOnly( constraint1, constraint2 ) ); + assertThat( getConstraints( db ), containsOnly( constraint1, constraint2 ) ); } @Test @@ -367,7 +369,7 @@ public void shouldDropUniquenessConstraint() dropConstraint( db, constraint ); // THEN - MatcherAssert.assertThat( Neo4jMatchers.getConstraints( db, label ), Neo4jMatchers.isEmpty() ); + assertThat( getConstraints( db, label ), isEmpty() ); } @Test diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/schema/UpdateDeletedIndexIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/schema/UpdateDeletedIndexIT.java index 7a6f1dbf49cf5..c1d1db3d89583 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/schema/UpdateDeletedIndexIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/schema/UpdateDeletedIndexIT.java @@ -89,7 +89,7 @@ private void shouldHandleIndexDropConcurrentlyWithOperation( NodeOperation opera for ( int i = 0; i < NODES; i++ ) { final long nodeId = nodes[i]; - race.addContestant( Race.throwing( () -> + race.addContestant( throwing( () -> { try ( Transaction tx = db.beginTx() ) { diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/RecoveryIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/RecoveryIT.java index 9f7a4e719e246..f4210a031098c 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/RecoveryIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/RecoveryIT.java @@ -102,6 +102,7 @@ import org.neo4j.test.rule.fs.DefaultFileSystemRule; import static java.lang.Long.max; +import static java.util.Arrays.asList; import static java.util.concurrent.TimeUnit.SECONDS; import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertEquals; @@ -113,6 +114,7 @@ import static org.neo4j.graphdb.RelationshipType.withName; import static org.neo4j.graphdb.facade.GraphDatabaseDependencies.newDependencies; import static org.neo4j.helpers.ArrayUtil.array; +import static org.neo4j.helpers.collection.Iterables.asList; import static org.neo4j.kernel.configuration.Config.defaults; public class RecoveryIT @@ -315,7 +317,7 @@ public void shouldSeeSameIndexUpdatesDuringRecoveryAsFromNormalIndexApplication( UpdateCapturingIndexProvider updateCapturingIndexProvider = new UpdateCapturingIndexProvider( indexProvider, new HashMap<>() ); EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction(); TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory() - .setKernelExtensions( Arrays.asList( new InMemoryIndexProviderFactory( updateCapturingIndexProvider ) ) ) + .setKernelExtensions( asList( new InMemoryIndexProviderFactory( updateCapturingIndexProvider ) ) ) .setFileSystem( fs ); GraphDatabaseService db = dbFactory.newImpermanentDatabase( storeDir ); Label label = TestLabels.LABEL_ONE; @@ -356,7 +358,7 @@ public void shouldSeeSameIndexUpdatesDuringRecoveryAsFromNormalIndexApplication( fs.close(); db = dbFactory .setFileSystem( crashedFs ) - .setKernelExtensions( Arrays.asList( new InMemoryIndexProviderFactory( recoveredUpdateCapturingIndexProvider ) ) ) + .setKernelExtensions( asList( new InMemoryIndexProviderFactory( recoveredUpdateCapturingIndexProvider ) ) ) .newImpermanentDatabase( storeDir ); long lastCommittedTxIdAfterRecovered = lastCommittedTxId( db ); Map>> updatesAfterRecovery = recoveredUpdateCapturingIndexProvider.snapshot(); @@ -628,7 +630,7 @@ else if ( operation < 0.9 ) private void onRandomRelationship( List nodes, Consumer action ) { - random.among( nodes, node -> random.among( Iterables.asList( node.getRelationships() ), action ) ); + random.among( nodes, node -> random.among( asList( node.getRelationships() ), action ) ); } private RelationshipType randomRelationshipType() diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/TestKernelExtension.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/TestKernelExtension.java index 4b7de890961ae..8a04ed2bca6ae 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/TestKernelExtension.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/TestKernelExtension.java @@ -19,7 +19,6 @@ */ package org.neo4j.kernel; -import org.junit.Assert; import org.junit.Test; import org.neo4j.kernel.configuration.Config; @@ -28,6 +27,8 @@ import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.lifecycle.LifecycleStatus; +import static org.junit.Assert.assertEquals; + /** * Test the implementation of the {@link org.neo4j.kernel.extension.KernelExtensionFactory} framework. Treats the * framework as a black box and takes the perspective of the extension, making @@ -54,7 +55,7 @@ public void shouldBeStarted() GraphDatabaseAPI graphdb = graphdb( 0 ); try { - Assert.assertEquals( LifecycleStatus.STARTED, graphdb.getDependencyResolver().resolveDependency( + assertEquals( LifecycleStatus.STARTED, graphdb.getDependencyResolver().resolveDependency( KernelExtensions.class ).resolveDependency( DummyExtension.class ).getStatus() ); } finally @@ -72,10 +73,10 @@ public void dependenciesCanBeRetrieved() GraphDatabaseAPI graphdb = graphdb( 0 ); try { - Assert.assertEquals( graphdb.getDependencyResolver().resolveDependency( Config.class ), + assertEquals( graphdb.getDependencyResolver().resolveDependency( Config.class ), graphdb.getDependencyResolver().resolveDependency( KernelExtensions.class ).resolveDependency( DummyExtension.class ).getDependencies().getConfig() ); - Assert.assertEquals( graphdb.getDependencyResolver().resolveDependency( NeoStoreDataSource.class ), + assertEquals( graphdb.getDependencyResolver().resolveDependency( NeoStoreDataSource.class ), graphdb.getDependencyResolver().resolveDependency( KernelExtensions.class ).resolveDependency( DummyExtension.class ).getDependencies().getNeoStoreDataSource().get() ); } @@ -94,7 +95,7 @@ public void shouldBeShutdown() GraphDatabaseAPI graphdb = graphdb( 0 ); graphdb.shutdown(); - Assert.assertEquals( LifecycleStatus.SHUTDOWN, graphdb.getDependencyResolver().resolveDependency( KernelExtensions + assertEquals( LifecycleStatus.SHUTDOWN, graphdb.getDependencyResolver().resolveDependency( KernelExtensions .class ).resolveDependency( DummyExtension.class ).getStatus() ); } } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java index 3aeff290e42f8..b46085e5191a2 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java @@ -56,9 +56,9 @@ public void testIndexSeekAndScanByString() throws Exception add( 2L, descriptor.schema(), "b", "b" ), add( 3L, descriptor.schema(), "a", "b" ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, "a" ), IndexQueryHelper.exact( 1, "a" ) ), equalTo( singletonList( 1L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, "b" ), IndexQueryHelper.exact( 1, "b" ) ), equalTo( singletonList( 2L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, "a" ), IndexQueryHelper.exact( 1, "b" ) ), equalTo( singletonList( 3L ) ) ); + assertThat( query( exact( 0, "a" ), exact( 1, "a" ) ), equalTo( singletonList( 1L ) ) ); + assertThat( query( exact( 0, "b" ), exact( 1, "b" ) ), equalTo( singletonList( 2L ) ) ); + assertThat( query( exact( 0, "a" ), exact( 1, "b" ) ), equalTo( singletonList( 3L ) ) ); assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) ); } @@ -70,9 +70,9 @@ public void testIndexSeekAndScanByNumber() throws Exception add( 2L, descriptor.schema(), 101, 101 ), add( 3L, descriptor.schema(), 333, 101 ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, 333 ), IndexQueryHelper.exact( 1, 333 ) ), equalTo( singletonList( 1L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, 101 ), IndexQueryHelper.exact( 1, 101 ) ), equalTo( singletonList( 2L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, 333 ), IndexQueryHelper.exact( 1, 101 ) ), equalTo( singletonList( 3L ) ) ); + assertThat( query( exact( 0, 333 ), exact( 1, 333 ) ), equalTo( singletonList( 1L ) ) ); + assertThat( query( exact( 0, 101 ), exact( 1, 101 ) ), equalTo( singletonList( 2L ) ) ); + assertThat( query( exact( 0, 333 ), exact( 1, 101 ) ), equalTo( singletonList( 3L ) ) ); assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) ); } @@ -93,12 +93,12 @@ public void testIndexSeekAndScanByPoint() throws Exception add( 6L, descriptor.schema(), gps, car3d ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, gps ), IndexQueryHelper.exact( 1, gps ) ), equalTo( singletonList( 1L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, car ), IndexQueryHelper.exact( 1, car ) ), equalTo( singletonList( 2L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, gps ), IndexQueryHelper.exact( 1, car ) ), equalTo( singletonList( 3L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, gps3d ), IndexQueryHelper.exact( 1, gps3d ) ), equalTo( singletonList( 4L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, car3d ), IndexQueryHelper.exact( 1, car3d ) ), equalTo( singletonList( 5L ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, gps ), IndexQueryHelper.exact( 1, car3d ) ), equalTo( singletonList( 6L ) ) ); + assertThat( query( exact( 0, gps ), exact( 1, gps ) ), equalTo( singletonList( 1L ) ) ); + assertThat( query( exact( 0, car ), exact( 1, car ) ), equalTo( singletonList( 2L ) ) ); + assertThat( query( exact( 0, gps ), exact( 1, car ) ), equalTo( singletonList( 3L ) ) ); + assertThat( query( exact( 0, gps3d ), exact( 1, gps3d ) ), equalTo( singletonList( 4L ) ) ); + assertThat( query( exact( 0, car3d ), exact( 1, car3d ) ), equalTo( singletonList( 5L ) ) ); + assertThat( query( exact( 0, gps ), exact( 1, car3d ) ), equalTo( singletonList( 6L ) ) ); assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L, 4L, 5L, 6L ) ) ); } @@ -119,7 +119,7 @@ public void testDuplicatesInIndexSeekByString() throws Exception add( 1L, descriptor.schema(), "a", "a" ), add( 2L, descriptor.schema(), "a", "a" ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, "a" ), IndexQueryHelper.exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); + assertThat( query( exact( 0, "a" ), exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); } @Test @@ -129,7 +129,7 @@ public void testDuplicatesInIndexSeekByNumber() throws Exception add( 1L, descriptor.schema(), 333, 333 ), add( 2L, descriptor.schema(), 333, 333 ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, 333 ), IndexQueryHelper.exact( 1, 333 ) ), equalTo( asList( 1L, 2L ) ) ); + assertThat( query( exact( 0, 333 ), exact( 1, 333 ) ), equalTo( asList( 1L, 2L ) ) ); } @Test @@ -140,7 +140,7 @@ public void testDuplicatesInIndexSeekByPoint() throws Exception add( 1L, descriptor.schema(), gps, gps ), add( 2L, descriptor.schema(), gps, gps ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, gps ), IndexQueryHelper.exact( 1, gps ) ), equalTo( asList( 1L, 2L ) ) ); + assertThat( query( exact( 0, gps ), exact( 1, gps ) ), equalTo( asList( 1L, 2L ) ) ); } } @@ -167,7 +167,7 @@ public void closingAnOnlineIndexUpdaterMustNotThrowEvenIfItHasBeenFedConflicting add( 1L, descriptor.schema(), "a", "a" ), add( 2L, descriptor.schema(), "a", "a" ) ) ); - assertThat( query( IndexQueryHelper.exact( 0, "a" ), IndexQueryHelper.exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); + assertThat( query( exact( 0, "a" ), exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); } } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java index 50581e0b092be..1367561fa6886 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java @@ -68,8 +68,8 @@ public void shouldProvidePopulatorThatAcceptsDuplicateEntries() throws Exception // when IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.defaults() ); withPopulator( indexProvider.getPopulator( descriptor, indexSamplingConfig ), p -> p.add( Arrays.asList( - IndexQueryHelper.add( 1, descriptor.schema(), "v1", "v2" ), - IndexQueryHelper.add( 2, descriptor.schema(), "v1", "v2" ) ) ) ); + add( 1, descriptor.schema(), "v1", "v2" ), + add( 2, descriptor.schema(), "v1", "v2" ) ) ) ); // then try ( IndexAccessor accessor = indexProvider.getOnlineAccessor( descriptor, indexSamplingConfig ) ) diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/SchemaLoggingIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/SchemaLoggingIT.java index 4c02ba844f88a..8213b658afe4d 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/SchemaLoggingIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/SchemaLoggingIT.java @@ -54,7 +54,7 @@ public void shouldLogUserReadableLabelAndPropertyNames() createIndex( db, labelName, property ); // then - LogMatcherBuilder match = AssertableLogProvider.inLog( IndexPopulationJob.class ); + LogMatcherBuilder match = inLog( IndexPopulationJob.class ); logProvider.assertAtLeastOnce( match.info( "Index population started: [%s]", ":User(name) [provider: {key=in-memory-index, version=1.0}]" ), match.info( "Index creation finished. Index [%s] is %s.", diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java index b4aeebb314d96..89faaf227068a 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java @@ -30,7 +30,6 @@ import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.index.Index; import org.neo4j.graphdb.index.IndexManager; -import org.neo4j.helpers.collection.MapUtil; import org.neo4j.kernel.impl.index.DummyIndexExtensionFactory; import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine; import org.neo4j.kernel.impl.store.NeoStores; @@ -44,6 +43,7 @@ import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.neo4j.helpers.collection.MapUtil.stringMap; public class TransactionRepresentationCommitProcessIT { @@ -60,7 +60,7 @@ public void commitDuringContinuousCheckpointing() throws Exception final Index index; try ( Transaction tx = db.beginTx() ) { - index = db.index().forNodes( INDEX_NAME, MapUtil.stringMap( + index = db.index().forNodes( INDEX_NAME, stringMap( IndexManager.PROVIDER, DummyIndexExtensionFactory.IDENTIFIER ) ); tx.success(); } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationIndexProvider.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationIndexProvider.java index d222be4bc8be7..336285e608e80 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationIndexProvider.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationIndexProvider.java @@ -41,6 +41,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.neo4j.internal.kernel.api.InternalIndexState.POPULATING; +import static org.neo4j.test.DoubleLatch.awaitLatch; public class ControlledPopulationIndexProvider extends IndexProvider { @@ -84,7 +85,7 @@ public IndexSample sampleResult() public void awaitFullyPopulated() { - DoubleLatch.awaitLatch( writerLatch ); + awaitLatch( writerLatch ); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java index 84440063f126c..962cc13e7a256 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java @@ -65,6 +65,8 @@ import static org.mockito.Mockito.when; import static org.neo4j.helpers.collection.Iterators.asSet; import static org.neo4j.helpers.collection.MapUtil.map; +import static org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.singleInstanceIndexProviderFactory; +import static org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.createIndex; public class IndexCRUDIT @@ -145,7 +147,7 @@ public void addingALabelToPreExistingNodeShouldGetIndexed() throws Exception public EphemeralFileSystemRule fs = new EphemeralFileSystemRule(); private final IndexProvider mockedIndexProvider = mock( IndexProvider.class ); private final KernelExtensionFactory mockedIndexProviderFactory = - SchemaIndexTestHelper.singleInstanceIndexProviderFactory( "none", mockedIndexProvider ); + singleInstanceIndexProviderFactory( "none", mockedIndexProvider ); private ThreadToStatementContextBridge ctxSupplier; private final Label myLabel = Label.label( "MYLABEL" ); @@ -166,7 +168,7 @@ private Node createNode( Map properties, Label ... labels ) @Before public void before() { - when( mockedIndexProvider.getProviderDescriptor() ).thenReturn( TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR ); + when( mockedIndexProvider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR ); when( mockedIndexProvider.storeMigrationParticipant( any( FileSystemAbstraction.class ), any( PageCache.class ) ) ) .thenReturn( StoreMigrationParticipant.NOT_PARTICIPATING ); TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory(); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java index c45c5d3979a10..327023d153ef4 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java @@ -340,7 +340,7 @@ public void shouldLogJobProgress() throws Exception job.run(); // Then - LogMatcherBuilder match = AssertableLogProvider.inLog( IndexPopulationJob.class ); + LogMatcherBuilder match = inLog( IndexPopulationJob.class ); logProvider.assertExactly( match.info( "Index population started: [%s]", ":FIRST(name)" ), match.info( "Index creation finished. Index [%s] is %s.", ":FIRST(name)", "ONLINE" ) @@ -386,7 +386,7 @@ public void shouldLogJobFailure() throws Exception job.run(); // Then - LogMatcherBuilder match = AssertableLogProvider.inLog( IndexPopulationJob.class ); + LogMatcherBuilder match = inLog( IndexPopulationJob.class ); logProvider.assertAtLeastOnce( match.error( is( "Failed to populate index: [:FIRST(name)]" ), sameInstance( failure ) ) ); @@ -650,8 +650,8 @@ private IndexDescriptor indexDescriptor( Label label, String propertyKey, boolea int propertyKeyId = tx.tokenWrite().propertyKeyGetOrCreateForName( propertyKey ); SchemaDescriptor schema = SchemaDescriptorFactory.forLabel( labelId, propertyKeyId ); IndexDescriptor descriptor = constraint ? - IndexDescriptorFactory.uniqueForSchema( schema, TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR ) : - IndexDescriptorFactory.forSchema( schema, TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR ); + IndexDescriptorFactory.uniqueForSchema( schema, PROVIDER_DESCRIPTOR ) : + IndexDescriptorFactory.forSchema( schema, PROVIDER_DESCRIPTOR ); tx.success(); return descriptor; } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java index 3b3a6b0b01dfb..275439841be18 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java @@ -74,6 +74,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.neo4j.graphdb.Label.label; +import static org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.singleInstanceIndexProviderFactory; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.getIndexes; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasSize; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.haveState; @@ -231,7 +232,7 @@ public void shouldKeepFailedIndexesAsFailedAfterRestart() throws Exception public EphemeralFileSystemRule fs = new EphemeralFileSystemRule(); private final IndexProvider mockedIndexProvider = mock( IndexProvider.class ); private final KernelExtensionFactory mockedIndexProviderFactory = - SchemaIndexTestHelper.singleInstanceIndexProviderFactory( TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR.getKey(), + singleInstanceIndexProviderFactory( TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR.getKey(), mockedIndexProvider ); private final String key = "number_of_bananas_owned"; private final Label myLabel = label( "MyLabel" ); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRestartIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRestartIT.java index 3c0b9e4bd6dee..a1fc1e46ffa94 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRestartIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexRestartIT.java @@ -20,9 +20,7 @@ package org.neo4j.kernel.impl.api.index; import org.hamcrest.CoreMatchers; -import org.hamcrest.Matchers; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -40,11 +38,14 @@ import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.rule.fs.EphemeralFileSystemRule; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.neo4j.graphdb.Label.label; import static org.neo4j.internal.kernel.api.InternalIndexState.ONLINE; import static org.neo4j.internal.kernel.api.InternalIndexState.POPULATING; +import static org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.singleInstanceIndexProviderFactory; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.getIndexState; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.getIndexes; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasSize; @@ -67,7 +68,7 @@ public void before() factory = new TestGraphDatabaseFactory(); factory.setFileSystem( new UncloseableDelegatingFileSystemAbstraction( fs.get() ) ); factory.setKernelExtensions( Collections.singletonList( - SchemaIndexTestHelper.singleInstanceIndexProviderFactory( "test", provider ) + singleInstanceIndexProviderFactory( "test", provider ) ) ); } @@ -123,8 +124,8 @@ public void shouldHandleRestartOfOnlineIndex() // Then assertThat( getIndexes( db, myLabel ), inTx( db, haveState( db, Schema.IndexState.ONLINE ) ) ); - Assert.assertEquals( 1, provider.populatorCallCount.get() ); - Assert.assertEquals( 2, provider.writerCallCount.get() ); + assertEquals( 1, provider.populatorCallCount.get() ); + assertEquals( 2, provider.writerCallCount.get() ); } @Test @@ -141,8 +142,8 @@ public void shouldHandleRestartIndexThatHasNotComeOnlineYet() // When startDb(); - assertThat( getIndexes( db, myLabel ), inTx( db, Matchers.not( haveState( db, Schema.IndexState.FAILED ) ) ) ); - Assert.assertEquals( 2, provider.populatorCallCount.get() ); + assertThat( getIndexes( db, myLabel ), inTx( db, not( haveState( db, Schema.IndexState.FAILED ) ) ) ); + assertEquals( 2, provider.populatorCallCount.get() ); } private IndexDefinition createIndex() diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsIT.java index 7bdbe541cd3c4..287629f601ee5 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsIT.java @@ -133,7 +133,7 @@ private void assertEqualRegisters( String message, DoubleLongRegister expected, private void assertLogExistsForRecoveryOn( String labelAndProperty ) { logProvider.assertAtLeastOnce( - AssertableLogProvider.inLog( IndexSamplingController.class ).debug( "Recovering index sampling for index %s", labelAndProperty ) + inLog( IndexSamplingController.class ).debug( "Recovering index sampling for index %s", labelAndProperty ) ); } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationConcurrencyIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationConcurrencyIT.java index acce862c66836..624e346a29547 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationConcurrencyIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationConcurrencyIT.java @@ -79,7 +79,7 @@ public void shouldPreventConcurrentCreationOfConflictingData() throws Exception } finally { - assertThat( otherThread, OtherThreadRule.isWaiting() ); + assertThat( otherThread, isWaiting() ); } } ); @@ -103,7 +103,7 @@ public void shouldAllowOtherTransactionToCompleteIfFirstTransactionRollsBack() t } finally { - assertThat( otherThread, OtherThreadRule.isWaiting() ); + assertThat( otherThread, isWaiting() ); } } ); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/state/NoChangeWriteTransactionTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/state/NoChangeWriteTransactionTest.java index 5b50e18b63914..6698cf6b21bed 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/state/NoChangeWriteTransactionTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/state/NoChangeWriteTransactionTest.java @@ -26,8 +26,6 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.index.Index; -import org.neo4j.helpers.collection.MapUtil; -import org.neo4j.kernel.impl.index.DummyIndexExtensionFactory; import org.neo4j.kernel.impl.transaction.log.TransactionIdStore; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.test.TestLabels; @@ -36,6 +34,8 @@ import static org.junit.Assert.assertEquals; import static org.neo4j.graphdb.index.IndexManager.PROVIDER; +import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.kernel.impl.index.DummyIndexExtensionFactory.IDENTIFIER; public class NoChangeWriteTransactionTest { @@ -92,7 +92,7 @@ private Index createNodeIndex( GraphDatabaseAPI db ) { try ( Transaction tx = db.beginTx() ) { - Index index = db.index().forNodes( "test", MapUtil.stringMap( PROVIDER, DummyIndexExtensionFactory.IDENTIFIER ) ); + Index index = db.index().forNodes( "test", stringMap( PROVIDER, IDENTIFIER ) ); tx.success(); return index; } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/NodeProxyTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/NodeProxyTest.java index db41632a19d48..a3ea63e793397 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/NodeProxyTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/NodeProxyTest.java @@ -38,7 +38,6 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.helpers.collection.Iterables; import org.neo4j.helpers.collection.Iterators; -import org.neo4j.test.DoubleLatch; import static java.util.Collections.singletonList; import static org.hamcrest.Matchers.containsString; @@ -51,6 +50,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.neo4j.helpers.NamedThreadFactory.named; +import static org.neo4j.test.DoubleLatch.awaitLatch; public class NodeProxyTest extends PropertyContainerProxyTest { @@ -267,7 +267,7 @@ public void getAllPropertiesShouldWorkFineWithConcurrentPropertyModifications() { try { - DoubleLatch.awaitLatch( start ); + awaitLatch( start ); int propertyKey = 0; while ( propertyKey < propertiesCount ) { @@ -292,7 +292,7 @@ public void getAllPropertiesShouldWorkFineWithConcurrentPropertyModifications() try ( Transaction tx = db.beginTx() ) { Node node = db.getNodeById( nodeId ); - DoubleLatch.awaitLatch( start ); + awaitLatch( start ); while ( !writerDone.get() ) { int size = node.getAllProperties().size(); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestLoopRelationships.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestLoopRelationships.java index 8f318d9370d2d..a81c522d3818f 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestLoopRelationships.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestLoopRelationships.java @@ -37,12 +37,12 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.helpers.collection.PrefetchingIterator; import org.neo4j.kernel.impl.AbstractNeo4jTestCase; -import org.neo4j.kernel.impl.MyRelTypes; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.neo4j.kernel.impl.MyRelTypes.TEST; public class TestLoopRelationships extends AbstractNeo4jTestCase { @@ -54,9 +54,9 @@ public void canCreateRelationshipBetweenTwoNodesWithLoopsThenDeleteOneOfTheNodes { Node source = getGraphDb().createNode(); Node target = getGraphDb().createNode(); - source.createRelationshipTo( source, MyRelTypes.TEST ); - target.createRelationshipTo( target, MyRelTypes.TEST ); - source.createRelationshipTo( target, MyRelTypes.TEST ); + source.createRelationshipTo( source, TEST ); + target.createRelationshipTo( target, TEST ); + source.createRelationshipTo( target, TEST ); newTransaction(); @@ -87,13 +87,13 @@ public void canDeleteNodeAfterDeletingItsRelationshipsIfThoseRelationshipsInclud private void txCreateRel( Node node ) { - node.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST ); + node.createRelationshipTo( getGraphDb().createNode(), TEST ); newTransaction(); } private void txCreateLoop( Node node ) { - node.createRelationshipTo( node, MyRelTypes.TEST ); + node.createRelationshipTo( node, TEST ); newTransaction(); } @@ -101,7 +101,7 @@ private void txCreateLoop( Node node ) public void canAddLoopRelationship() { Node node = getGraphDb().createNode(); - node.createRelationshipTo( node, MyRelTypes.TEST ); + node.createRelationshipTo( node, TEST ); newTransaction(); @@ -137,11 +137,11 @@ private void testAddManyLoopRelationships( int count ) { if ( loop[i] ) { - relationships[i] = root.createRelationshipTo( root, MyRelTypes.TEST ); + relationships[i] = root.createRelationshipTo( root, TEST ); } else { - relationships[i] = root.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST ); + relationships[i] = root.createRelationshipTo( getGraphDb().createNode(), TEST ); } } newTransaction(); @@ -181,16 +181,16 @@ public void canAddAndRemoveLoopRelationshipAndOtherRelationships() public void getSingleRelationshipOnNodeWithOneLoopOnly() { Node node = getGraphDb().createNode(); - Relationship singleRelationship = node.createRelationshipTo( node, MyRelTypes.TEST ); - assertEquals( singleRelationship, node.getSingleRelationship( MyRelTypes.TEST, Direction.OUTGOING ) ); - assertEquals( singleRelationship, node.getSingleRelationship( MyRelTypes.TEST, Direction.INCOMING ) ); - assertEquals( singleRelationship, node.getSingleRelationship( MyRelTypes.TEST, Direction.BOTH ) ); + Relationship singleRelationship = node.createRelationshipTo( node, TEST ); + assertEquals( singleRelationship, node.getSingleRelationship( TEST, Direction.OUTGOING ) ); + assertEquals( singleRelationship, node.getSingleRelationship( TEST, Direction.INCOMING ) ); + assertEquals( singleRelationship, node.getSingleRelationship( TEST, Direction.BOTH ) ); commit(); newTransaction(); - assertEquals( singleRelationship, node.getSingleRelationship( MyRelTypes.TEST, Direction.OUTGOING ) ); - assertEquals( singleRelationship, node.getSingleRelationship( MyRelTypes.TEST, Direction.INCOMING ) ); - assertEquals( singleRelationship, node.getSingleRelationship( MyRelTypes.TEST, Direction.BOTH ) ); + assertEquals( singleRelationship, node.getSingleRelationship( TEST, Direction.OUTGOING ) ); + assertEquals( singleRelationship, node.getSingleRelationship( TEST, Direction.INCOMING ) ); + assertEquals( singleRelationship, node.getSingleRelationship( TEST, Direction.BOTH ) ); finish(); } @@ -225,7 +225,7 @@ public void cannotDeleteNodeWithLoopStillAttached() public void getOtherNodeFunctionsCorrectly() { Node node = getGraphDb().createNode(); - Relationship relationship = node.createRelationshipTo( node, MyRelTypes.TEST ); + Relationship relationship = node.createRelationshipTo( node, TEST ); // This loop messes up the readability of the test case, but avoids duplicated // assertion code. Same assertions withing the transaction as after it has committed. @@ -249,11 +249,11 @@ public void getOtherNodeFunctionsCorrectly() public void getNewlyCreatedLoopRelationshipFromCache() { Node node = getGraphDb().createNode(); - node.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST ); + node.createRelationshipTo( getGraphDb().createNode(), TEST ); newTransaction(); - Relationship relationship = node.createRelationshipTo( node, MyRelTypes.TEST ); + Relationship relationship = node.createRelationshipTo( node, TEST ); newTransaction(); - assertEquals( relationship, node.getSingleRelationship( MyRelTypes.TEST, Direction.INCOMING ) ); + assertEquals( relationship, node.getSingleRelationship( TEST, Direction.INCOMING ) ); } private void testAddAndRemoveLoopRelationshipAndOtherRelationships( int size ) @@ -328,7 +328,7 @@ private Relationship[] createRelationships( int count, int loop, Node root ) Relationship[] relationships = new Relationship[count]; for ( int i = 0; i < count; i++ ) { - relationships[i] = root.createRelationshipTo( nodes[i], MyRelTypes.TEST ); + relationships[i] = root.createRelationshipTo( nodes[i], TEST ); newTransaction(); } return relationships; diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestReadOnlyNeo4j.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestReadOnlyNeo4j.java index ea76b8e805456..4e22aab280b00 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestReadOnlyNeo4j.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestReadOnlyNeo4j.java @@ -19,7 +19,6 @@ */ package org.neo4j.kernel.impl.core; -import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -62,7 +61,7 @@ public void testSimple() .newImpermanentDatabaseBuilder( PATH ) .setConfig( GraphDatabaseSettings.read_only, Settings.TRUE ) .newGraphDatabase(); - Assert.assertEquals( someData, DbRepresentation.of( readGraphDb ) ); + assertEquals( someData, DbRepresentation.of( readGraphDb ) ); try ( Transaction tx = readGraphDb.beginTx() ) { diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationship.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationship.java index caf7ce271e261..e66da6259a4fe 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationship.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationship.java @@ -37,7 +37,6 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.helpers.collection.Iterables; import org.neo4j.kernel.impl.AbstractNeo4jTestCase; -import org.neo4j.kernel.impl.MyRelTypes; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -46,6 +45,8 @@ import static org.junit.Assert.fail; import static org.neo4j.graphdb.RelationshipType.withName; import static org.neo4j.kernel.impl.MyRelTypes.TEST; +import static org.neo4j.kernel.impl.MyRelTypes.TEST2; +import static org.neo4j.kernel.impl.MyRelTypes.TEST_TRAVERSAL; public class TestRelationship extends AbstractNeo4jTestCase { @@ -58,16 +59,16 @@ public void testSimple() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); - node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); + node1.createRelationshipTo( node2, TEST ); rel1.delete(); newTransaction(); assertHasNext( (ResourceIterable) node1.getRelationships() ); assertHasNext( (ResourceIterable) node2.getRelationships() ); - assertHasNext( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST ) ); - assertHasNext( (ResourceIterable) node2.getRelationships( MyRelTypes.TEST ) ); - assertHasNext( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); - assertHasNext( (ResourceIterable) node2.getRelationships( MyRelTypes.TEST, Direction.INCOMING ) ); + assertHasNext( (ResourceIterable) node1.getRelationships( TEST ) ); + assertHasNext( (ResourceIterable) node2.getRelationships( TEST ) ); + assertHasNext( (ResourceIterable) node1.getRelationships( TEST, Direction.OUTGOING ) ); + assertHasNext( (ResourceIterable) node2.getRelationships( TEST, Direction.INCOMING ) ); } @Test @@ -77,21 +78,21 @@ public void testSimple2() Node node2 = getGraphDb().createNode(); for ( int i = 0; i < 3; i++ ) { - node1.createRelationshipTo( node2, MyRelTypes.TEST ); - node1.createRelationshipTo( node2, MyRelTypes.TEST_TRAVERSAL ); - node1.createRelationshipTo( node2, MyRelTypes.TEST2 ); + node1.createRelationshipTo( node2, TEST ); + node1.createRelationshipTo( node2, TEST_TRAVERSAL ); + node1.createRelationshipTo( node2, TEST2 ); } allGetRelationshipMethods( node1, Direction.OUTGOING ); allGetRelationshipMethods( node2, Direction.INCOMING ); newTransaction(); allGetRelationshipMethods( node1, Direction.OUTGOING ); allGetRelationshipMethods( node2, Direction.INCOMING ); - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST_TRAVERSAL, Direction.OUTGOING ) ); - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST2, Direction.OUTGOING ) ); - node1.createRelationshipTo( node2, MyRelTypes.TEST ); - node1.createRelationshipTo( node2, MyRelTypes.TEST_TRAVERSAL ); - node1.createRelationshipTo( node2, MyRelTypes.TEST2 ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST, Direction.OUTGOING ) ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST_TRAVERSAL, Direction.OUTGOING ) ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST2, Direction.OUTGOING ) ); + node1.createRelationshipTo( node2, TEST ); + node1.createRelationshipTo( node2, TEST_TRAVERSAL ); + node1.createRelationshipTo( node2, TEST2 ); allGetRelationshipMethods( node1, Direction.OUTGOING ); allGetRelationshipMethods( node2, Direction.INCOMING ); newTransaction(); @@ -112,21 +113,21 @@ public void testSimple3() Node node2 = getGraphDb().createNode(); for ( int i = 0; i < 1; i++ ) { - node1.createRelationshipTo( node2, MyRelTypes.TEST ); - node1.createRelationshipTo( node2, MyRelTypes.TEST_TRAVERSAL ); - node1.createRelationshipTo( node2, MyRelTypes.TEST2 ); + node1.createRelationshipTo( node2, TEST ); + node1.createRelationshipTo( node2, TEST_TRAVERSAL ); + node1.createRelationshipTo( node2, TEST2 ); } allGetRelationshipMethods2( node1, Direction.OUTGOING ); allGetRelationshipMethods2( node2, Direction.INCOMING ); newTransaction(); allGetRelationshipMethods2( node1, Direction.OUTGOING ); allGetRelationshipMethods2( node2, Direction.INCOMING ); - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST_TRAVERSAL, Direction.OUTGOING ) ); - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST2, Direction.OUTGOING ) ); - node1.createRelationshipTo( node2, MyRelTypes.TEST ); - node1.createRelationshipTo( node2, MyRelTypes.TEST_TRAVERSAL ); - node1.createRelationshipTo( node2, MyRelTypes.TEST2 ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST, Direction.OUTGOING ) ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST_TRAVERSAL, Direction.OUTGOING ) ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST2, Direction.OUTGOING ) ); + node1.createRelationshipTo( node2, TEST ); + node1.createRelationshipTo( node2, TEST_TRAVERSAL ); + node1.createRelationshipTo( node2, TEST2 ); allGetRelationshipMethods2( node1, Direction.OUTGOING ); allGetRelationshipMethods2( node2, Direction.INCOMING ); newTransaction(); @@ -147,18 +148,18 @@ public void testSimple4() Node node2 = getGraphDb().createNode(); for ( int i = 0; i < 2; i++ ) { - node1.createRelationshipTo( node2, MyRelTypes.TEST ); - node1.createRelationshipTo( node2, MyRelTypes.TEST_TRAVERSAL ); - node1.createRelationshipTo( node2, MyRelTypes.TEST2 ); + node1.createRelationshipTo( node2, TEST ); + node1.createRelationshipTo( node2, TEST_TRAVERSAL ); + node1.createRelationshipTo( node2, TEST2 ); } allGetRelationshipMethods3( node1, Direction.OUTGOING ); allGetRelationshipMethods3( node2, Direction.INCOMING ); newTransaction(); allGetRelationshipMethods3( node1, Direction.OUTGOING ); allGetRelationshipMethods3( node2, Direction.INCOMING ); - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST, Direction.OUTGOING ) ); int count = 0; - for ( Relationship rel : node1.getRelationships( MyRelTypes.TEST_TRAVERSAL, Direction.OUTGOING ) ) + for ( Relationship rel : node1.getRelationships( TEST_TRAVERSAL, Direction.OUTGOING ) ) { if ( count == 1 ) { @@ -166,10 +167,10 @@ public void testSimple4() } count++; } - deleteFirst( (ResourceIterable) node1.getRelationships( MyRelTypes.TEST2, Direction.OUTGOING ) ); - node1.createRelationshipTo( node2, MyRelTypes.TEST ); - node1.createRelationshipTo( node2, MyRelTypes.TEST_TRAVERSAL ); - node1.createRelationshipTo( node2, MyRelTypes.TEST2 ); + deleteFirst( (ResourceIterable) node1.getRelationships( TEST2, Direction.OUTGOING ) ); + node1.createRelationshipTo( node2, TEST ); + node1.createRelationshipTo( node2, TEST_TRAVERSAL ); + node1.createRelationshipTo( node2, TEST2 ); allGetRelationshipMethods3( node1, Direction.OUTGOING ); allGetRelationshipMethods3( node2, Direction.INCOMING ); newTransaction(); @@ -187,48 +188,48 @@ private void allGetRelationshipMethods( Node node, Direction dir ) { countRelationships( 9, node.getRelationships() ); countRelationships( 9, node.getRelationships( dir ) ); - countRelationships( 9, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 6, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST2 ) ); - countRelationships( 6, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 6, node.getRelationships( MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 3, node.getRelationships( MyRelTypes.TEST ) ); - countRelationships( 3, node.getRelationships( MyRelTypes.TEST2 ) ); - countRelationships( 3, node.getRelationships( MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 3, node.getRelationships( MyRelTypes.TEST, dir ) ); - countRelationships( 3, node.getRelationships( MyRelTypes.TEST2, dir ) ); - countRelationships( 3, node.getRelationships( MyRelTypes.TEST_TRAVERSAL, dir ) ); + countRelationships( 9, node.getRelationships( TEST, TEST2, TEST_TRAVERSAL ) ); + countRelationships( 6, node.getRelationships( TEST, TEST2 ) ); + countRelationships( 6, node.getRelationships( TEST, TEST_TRAVERSAL ) ); + countRelationships( 6, node.getRelationships( TEST2, TEST_TRAVERSAL ) ); + countRelationships( 3, node.getRelationships( TEST ) ); + countRelationships( 3, node.getRelationships( TEST2 ) ); + countRelationships( 3, node.getRelationships( TEST_TRAVERSAL ) ); + countRelationships( 3, node.getRelationships( TEST, dir ) ); + countRelationships( 3, node.getRelationships( TEST2, dir ) ); + countRelationships( 3, node.getRelationships( TEST_TRAVERSAL, dir ) ); } private void allGetRelationshipMethods2( Node node, Direction dir ) { countRelationships( 3, node.getRelationships() ); countRelationships( 3, node.getRelationships( dir ) ); - countRelationships( 3, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST2 ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 1, node.getRelationships( MyRelTypes.TEST ) ); - countRelationships( 1, node.getRelationships( MyRelTypes.TEST2 ) ); - countRelationships( 1, node.getRelationships( MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 1, node.getRelationships( MyRelTypes.TEST, dir ) ); - countRelationships( 1, node.getRelationships( MyRelTypes.TEST2, dir ) ); - countRelationships( 1, node.getRelationships( MyRelTypes.TEST_TRAVERSAL, dir ) ); + countRelationships( 3, node.getRelationships( TEST, TEST2, TEST_TRAVERSAL ) ); + countRelationships( 2, node.getRelationships( TEST, TEST2 ) ); + countRelationships( 2, node.getRelationships( TEST, TEST_TRAVERSAL ) ); + countRelationships( 2, node.getRelationships( TEST2, TEST_TRAVERSAL ) ); + countRelationships( 1, node.getRelationships( TEST ) ); + countRelationships( 1, node.getRelationships( TEST2 ) ); + countRelationships( 1, node.getRelationships( TEST_TRAVERSAL ) ); + countRelationships( 1, node.getRelationships( TEST, dir ) ); + countRelationships( 1, node.getRelationships( TEST2, dir ) ); + countRelationships( 1, node.getRelationships( TEST_TRAVERSAL, dir ) ); } private void allGetRelationshipMethods3( Node node, Direction dir ) { countRelationships( 6, node.getRelationships() ); countRelationships( 6, node.getRelationships( dir ) ); - countRelationships( 6, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 4, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST2 ) ); - countRelationships( 4, node.getRelationships( MyRelTypes.TEST, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 4, node.getRelationships( MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST2 ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST_TRAVERSAL ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST, dir ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST2, dir ) ); - countRelationships( 2, node.getRelationships( MyRelTypes.TEST_TRAVERSAL, dir ) ); + countRelationships( 6, node.getRelationships( TEST, TEST2, TEST_TRAVERSAL ) ); + countRelationships( 4, node.getRelationships( TEST, TEST2 ) ); + countRelationships( 4, node.getRelationships( TEST, TEST_TRAVERSAL ) ); + countRelationships( 4, node.getRelationships( TEST2, TEST_TRAVERSAL ) ); + countRelationships( 2, node.getRelationships( TEST ) ); + countRelationships( 2, node.getRelationships( TEST2 ) ); + countRelationships( 2, node.getRelationships( TEST_TRAVERSAL ) ); + countRelationships( 2, node.getRelationships( TEST, dir ) ); + countRelationships( 2, node.getRelationships( TEST2, dir ) ); + countRelationships( 2, node.getRelationships( TEST_TRAVERSAL, dir ) ); } private void countRelationships( int expectedCount, Iterable rels ) @@ -254,26 +255,26 @@ public void testRelationshipCreateAndDelete() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship relationship = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship relationship = node1.createRelationshipTo( node2, TEST ); Relationship[] relArray1 = getRelationshipArray( node1.getRelationships() ); Relationship[] relArray2 = getRelationshipArray( node2.getRelationships() ); assertEquals( 1, relArray1.length ); assertEquals( relationship, relArray1[0] ); assertEquals( 1, relArray2.length ); assertEquals( relationship, relArray2[0] ); - relArray1 = getRelationshipArray( node1.getRelationships( MyRelTypes.TEST ) ); + relArray1 = getRelationshipArray( node1.getRelationships( TEST ) ); assertEquals( 1, relArray1.length ); assertEquals( relationship, relArray1[0] ); - relArray2 = getRelationshipArray( node2.getRelationships( MyRelTypes.TEST ) ); + relArray2 = getRelationshipArray( node2.getRelationships( TEST ) ); assertEquals( 1, relArray2.length ); assertEquals( relationship, relArray2[0] ); - relArray1 = getRelationshipArray( node1.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); + relArray1 = getRelationshipArray( node1.getRelationships( TEST, Direction.OUTGOING ) ); assertEquals( 1, relArray1.length ); - relArray2 = getRelationshipArray( node2.getRelationships( MyRelTypes.TEST, Direction.INCOMING ) ); + relArray2 = getRelationshipArray( node2.getRelationships( TEST, Direction.INCOMING ) ); assertEquals( 1, relArray2.length ); - relArray1 = getRelationshipArray( node1.getRelationships( MyRelTypes.TEST, Direction.INCOMING ) ); + relArray1 = getRelationshipArray( node1.getRelationships( TEST, Direction.INCOMING ) ); assertEquals( 0, relArray1.length ); - relArray2 = getRelationshipArray( node2.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); + relArray2 = getRelationshipArray( node2.getRelationships( TEST, Direction.OUTGOING ) ); assertEquals( 0, relArray2.length ); relationship.delete(); node2.delete(); @@ -296,7 +297,7 @@ public void testDeleteWithRelationship() // do some evil stuff Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - node1.createRelationshipTo( node2, MyRelTypes.TEST ); + node1.createRelationshipTo( node2, TEST ); node1.delete(); node2.delete(); try @@ -317,7 +318,7 @@ public void testDeletedRelationship() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship relationship = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship relationship = node1.createRelationshipTo( node2, TEST ); relationship.delete(); try { @@ -336,7 +337,7 @@ public void testRelationshipAddPropertyWithNullKey() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); try { @@ -354,7 +355,7 @@ public void testRelationshipAddPropertyWithNullValue() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); try { @@ -373,8 +374,8 @@ public void testRelationshipAddProperty() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); - Relationship rel2 = node2.createRelationshipTo( node1, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); + Relationship rel2 = node2.createRelationshipTo( node1, TEST ); Integer int1 = 1; Integer int2 = 2; @@ -410,8 +411,8 @@ public void testRelationshipRemoveProperty() Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); - Relationship rel2 = node2.createRelationshipTo( node1, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); + Relationship rel2 = node2.createRelationshipTo( node1, TEST ); // verify that we can rely on PL to reomve non existing properties try { @@ -477,8 +478,8 @@ public void testRelationshipChangeProperty() Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); - Relationship rel2 = node2.createRelationshipTo( node1, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); + Relationship rel2 = node2.createRelationshipTo( node1, TEST ); rel1.setProperty( key1, int1 ); rel2.setProperty( key1, string1 ); rel1.setProperty( key2, string2 ); @@ -517,7 +518,7 @@ public void testRelationshipChangeProperty2() Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); rel1.setProperty( key1, int1 ); rel1.setProperty( key1, int2 ); assertEquals( int2, rel1.getProperty( key1 ) ); @@ -545,7 +546,7 @@ public void testRelGetProperties() Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); try { rel1.getProperty( key1 ); @@ -624,8 +625,8 @@ public void testDirectedRelationship() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel2 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); - Relationship rel3 = node2.createRelationshipTo( node1, MyRelTypes.TEST ); + Relationship rel2 = node1.createRelationshipTo( node2, TEST ); + Relationship rel3 = node2.createRelationshipTo( node1, TEST ); Node[] nodes = rel2.getNodes(); assertEquals( 2, nodes.length ); assertTrue( nodes[0].equals( node1 ) && nodes[1].equals( node2 ) ); @@ -637,17 +638,17 @@ public void testDirectedRelationship() assertEquals( node2, rel3.getStartNode() ); assertEquals( node1, rel3.getEndNode() ); - Relationship[] relArray = getRelationshipArray( node1.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); + Relationship[] relArray = getRelationshipArray( node1.getRelationships( TEST, Direction.OUTGOING ) ); assertEquals( 1, relArray.length ); assertEquals( rel2, relArray[0] ); - relArray = getRelationshipArray( node1.getRelationships( MyRelTypes.TEST, Direction.INCOMING ) ); + relArray = getRelationshipArray( node1.getRelationships( TEST, Direction.INCOMING ) ); assertEquals( 1, relArray.length ); assertEquals( rel3, relArray[0] ); - relArray = getRelationshipArray( node2.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); + relArray = getRelationshipArray( node2.getRelationships( TEST, Direction.OUTGOING ) ); assertEquals( 1, relArray.length ); assertEquals( rel3, relArray[0] ); - relArray = getRelationshipArray( node2.getRelationships( MyRelTypes.TEST, Direction.INCOMING ) ); + relArray = getRelationshipArray( node2.getRelationships( TEST, Direction.INCOMING ) ); assertEquals( 1, relArray.length ); assertEquals( rel2, relArray[0] ); @@ -662,7 +663,7 @@ public void testRollbackDeleteRelationship() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel1 = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel1 = node1.createRelationshipTo( node2, TEST ); newTransaction(); node1.delete(); rel1.delete(); @@ -681,7 +682,7 @@ public void testCreateRelationshipWithCommitts()// throws NotFoundException newTransaction(); n1 = getGraphDb().getNodeById( n1.getId() ); Node n2 = getGraphDb().createNode(); - n1.createRelationshipTo( n2, MyRelTypes.TEST ); + n1.createRelationshipTo( n2, TEST ); newTransaction(); Relationship[] relArray = getRelationshipArray( n1.getRelationships() ); assertEquals( 1, relArray.length ); @@ -696,7 +697,7 @@ public void testAddPropertyThenDelete() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel = node1.createRelationshipTo( node2, TEST ); rel.setProperty( "test", "test" ); newTransaction(); rel.setProperty( "test2", "test2" ); @@ -711,10 +712,10 @@ public void testRelationshipIsType() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel = node1.createRelationshipTo( node2, MyRelTypes.TEST ); - assertTrue( rel.isType( MyRelTypes.TEST ) ); - assertTrue( rel.isType( MyRelTypes.TEST::name ) ); - assertFalse( rel.isType( MyRelTypes.TEST_TRAVERSAL ) ); + Relationship rel = node1.createRelationshipTo( node2, TEST ); + assertTrue( rel.isType( TEST ) ); + assertTrue( rel.isType( TEST::name ) ); + assertFalse( rel.isType( TEST_TRAVERSAL ) ); rel.delete(); node1.delete(); node2.delete(); @@ -725,7 +726,7 @@ public void testChangeProperty() { Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel = node1.createRelationshipTo( node2, TEST ); rel.setProperty( "test", "test1" ); newTransaction(); rel.setProperty( "test", "test2" ); @@ -744,7 +745,7 @@ public void testChangeProperty2() // Create relationship with "test"="test1" Node node1 = getGraphDb().createNode(); Node node2 = getGraphDb().createNode(); - Relationship rel = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship rel = node1.createRelationshipTo( node2, TEST ); rel.setProperty( "test", "test1" ); newTransaction(); // commit @@ -839,13 +840,13 @@ public void createRelationshipAfterClearedCache() int expectedCount = 0; for ( int i = 0; i < 150; i++ ) { - node1.createRelationshipTo( node2, MyRelTypes.TEST ); + node1.createRelationshipTo( node2, TEST ); expectedCount++; } newTransaction(); for ( int i = 0; i < 50; i++ ) { - node1.createRelationshipTo( node2, MyRelTypes.TEST ); + node1.createRelationshipTo( node2, TEST ); expectedCount++; } assertEquals( expectedCount, Iterables.count( node1.getRelationships() ) ); @@ -863,7 +864,7 @@ public void getAllRelationships() Node node = getGraphDb().createNode(); for ( int i = 0; i < 100; i++ ) { - createdRelationships.add( node.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST ) ); + createdRelationships.add( node.createRelationshipTo( getGraphDb().createNode(), TEST ) ); } newTransaction(); @@ -885,7 +886,7 @@ public void getAllRelationships() public void createAndClearCacheBeforeCommit() { Node node = getGraphDb().createNode(); - node.createRelationshipTo( getGraphDb().createNode(), MyRelTypes.TEST ); + node.createRelationshipTo( getGraphDb().createNode(), TEST ); assertEquals( 1, Iterables.count( node.getRelationships() ) ); } @@ -922,8 +923,8 @@ public void shouldLoadAllRelationships() node = db.createNode(); for ( int i = 0; i < 112; i++ ) { - node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); - db.createNode().createRelationshipTo( node, MyRelTypes.TEST ); + node.createRelationshipTo( db.createNode(), TEST ); + db.createNode().createRelationshipTo( node, TEST ); } tx.success(); } @@ -932,8 +933,8 @@ public void shouldLoadAllRelationships() long two; try ( Transaction tx = db.beginTx() ) { - one = Iterables.count( node.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); - two = Iterables.count( node.getRelationships( MyRelTypes.TEST, Direction.OUTGOING ) ); + one = Iterables.count( node.getRelationships( TEST, Direction.OUTGOING ) ); + two = Iterables.count( node.getRelationships( TEST, Direction.OUTGOING ) ); tx.success(); } @@ -950,7 +951,7 @@ public void deletionOfSameRelationshipTwiceInOneTransactionShouldNotRollbackIt() // transaction is opened by test Node node1 = db.createNode(); Node node2 = db.createNode(); - Relationship relationship = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship relationship = node1.createRelationshipTo( node2, TEST ); commit(); // When @@ -989,7 +990,7 @@ public void deletionOfAlreadyDeletedRelationshipShouldThrow() // transaction is opened by test Node node1 = db.createNode(); Node node2 = db.createNode(); - Relationship relationship = node1.createRelationshipTo( node2, MyRelTypes.TEST ); + Relationship relationship = node1.createRelationshipTo( node2, TEST ); commit(); try ( Transaction tx = db.beginTx() ) diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationshipCount.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationshipCount.java index 0feee6414de5a..06dd00b99aa79 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationshipCount.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestRelationshipCount.java @@ -21,7 +21,6 @@ import org.junit.After; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -247,8 +246,8 @@ public void withoutLoops() assertEquals( 1002, node1.getDegree( Direction.BOTH ) ); assertEquals( 502, node1.getDegree( Direction.OUTGOING ) ); assertEquals( 500, node1.getDegree( Direction.INCOMING ) ); - Assert.assertEquals( 1, node1.getDegree( MyRelTypes.TEST2 ) ); - Assert.assertEquals( 1001, node1.getDegree( MyRelTypes.TEST ) ); + assertEquals( 1, node1.getDegree( MyRelTypes.TEST2 ) ); + assertEquals( 1001, node1.getDegree( MyRelTypes.TEST ) ); assertEquals( 1001, node1.getDegree( MyRelTypes.TEST, Direction.BOTH ) ); assertEquals( 501, node1.getDegree( MyRelTypes.TEST, Direction.OUTGOING ) ); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShortStringProperties.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShortStringProperties.java index adb243f5bcad5..7cad611aa11ff 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShortStringProperties.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShortStringProperties.java @@ -19,7 +19,6 @@ */ package org.neo4j.kernel.impl.core; -import org.hamcrest.Matchers; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; @@ -34,6 +33,7 @@ import org.neo4j.test.rule.GraphTransactionRule; import org.neo4j.test.rule.ImpermanentDatabaseRule; +import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -178,7 +178,7 @@ public void canRemoveShortStringProperty() assertEquals( recordCount, dynamicRecordsInUse() ); assertEquals( propCount, propertyRecordsInUse() ); - assertThat( node, inTx( db, Matchers.not( hasProperty( "key" ) ) ) ); + assertThat( node, inTx( db, not( hasProperty( "key" ) ) ) ); } @Test diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/event/TestTransactionEvents.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/event/TestTransactionEvents.java index 418fb74f0e109..d2cd5eeb1249a 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/event/TestTransactionEvents.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/event/TestTransactionEvents.java @@ -46,11 +46,8 @@ import org.neo4j.graphdb.event.TransactionData; import org.neo4j.graphdb.event.TransactionEventHandler; import org.neo4j.helpers.Exceptions; -import org.neo4j.helpers.collection.MapUtil; import org.neo4j.kernel.impl.MyRelTypes; -import org.neo4j.kernel.impl.index.DummyIndexExtensionFactory; import org.neo4j.test.TestLabels; -import org.neo4j.test.mockito.matcher.Neo4jMatchers; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.ImpermanentDatabaseRule; @@ -68,6 +65,9 @@ import static org.neo4j.graphdb.RelationshipType.withName; import static org.neo4j.graphdb.index.IndexManager.PROVIDER; import static org.neo4j.helpers.collection.Iterables.count; +import static org.neo4j.helpers.collection.MapUtil.stringMap; +import static org.neo4j.kernel.impl.index.DummyIndexExtensionFactory.IDENTIFIER; +import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasProperty; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.inTx; public class TestTransactionEvents @@ -675,7 +675,7 @@ public Void beforeCommit( TransactionData data ) tx.success(); } // Then - assertThat(node, inTx(db, Neo4jMatchers.hasProperty(key).withValue(value2))); + assertThat(node, inTx(db, hasProperty(key).withValue(value2))); db.unregisterTransactionEventHandler( handler ); } @@ -1060,7 +1060,7 @@ public Void beforeCommit( TransactionData data ) // ... or even an explicit index try ( Transaction tx = dbRule.beginTx() ) { - dbRule.index().forNodes( "some index", MapUtil.stringMap( PROVIDER, DummyIndexExtensionFactory.IDENTIFIER ) ); + dbRule.index().forNodes( "some index", stringMap( PROVIDER, IDENTIFIER ) ); tx.success(); } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/recovery/KernelRecoveryTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/recovery/KernelRecoveryTest.java index dae3988b71ccd..0628b33134e20 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/recovery/KernelRecoveryTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/recovery/KernelRecoveryTest.java @@ -19,7 +19,6 @@ */ package org.neo4j.kernel.impl.recovery; -import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; @@ -37,12 +36,13 @@ import org.neo4j.kernel.impl.transaction.log.LogPosition; import org.neo4j.kernel.impl.transaction.log.files.TransactionLogFiles; import org.neo4j.test.TestGraphDatabaseFactory; -import org.neo4j.test.mockito.matcher.LogMatchers; import org.neo4j.test.rule.fs.EphemeralFileSystemRule; +import static org.hamcrest.MatcherAssert.assertThat; import static org.neo4j.test.mockito.matcher.LogMatchers.checkPoint; import static org.neo4j.test.mockito.matcher.LogMatchers.commandEntry; import static org.neo4j.test.mockito.matcher.LogMatchers.commitEntry; +import static org.neo4j.test.mockito.matcher.LogMatchers.containsExactly; import static org.neo4j.test.mockito.matcher.LogMatchers.logEntries; import static org.neo4j.test.mockito.matcher.LogMatchers.startEntry; @@ -72,7 +72,7 @@ public void shouldHandleWritesProperlyAfterRecovery() throws Exception // Then the logical log should be in sync File logFile = new File( storeDir, TransactionLogFiles.DEFAULT_NAME + ".0" ); - MatcherAssert.assertThat( logEntries( crashedFs, logFile ), LogMatchers.containsExactly( + assertThat( logEntries( crashedFs, logFile ), containsExactly( // Tx before recovery startEntry( -1, -1 ), commandEntry( node1, NodeCommand.class ), commandEntry( StatementConstants.ANY_LABEL, NodeCountsCommand.class ), commitEntry( 2 ), diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReaderRelTypesAndDegreeTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReaderRelTypesAndDegreeTest.java index 4f62ebb9bc62e..4d9e072377641 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReaderRelTypesAndDegreeTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReaderRelTypesAndDegreeTest.java @@ -31,7 +31,6 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.GraphDatabaseSettings; -import org.neo4j.helpers.collection.Iterators; import org.neo4j.kernel.impl.core.RelationshipTypeTokenHolder; import org.neo4j.kernel.impl.core.TokenNotFoundException; import org.neo4j.kernel.impl.store.NeoStores; @@ -364,11 +363,11 @@ public void relationshipTypesForDenseNodeWithPartiallyDeletedRelGroupChain() asSet( IN, OUT ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, IN, OUT ), - Iterators.asSet( LOOP ) ); + asSet( LOOP ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, IN, LOOP ), - Iterators.asSet( OUT ) ); + asSet( OUT ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, OUT, LOOP ), - Iterators.asSet( IN ) ); + asSet( IN ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, IN, OUT, LOOP ), diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipChainPointerChasingTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipChainPointerChasingTest.java index 216a8d992530c..08654094e6973 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipChainPointerChasingTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipChainPointerChasingTest.java @@ -28,7 +28,6 @@ import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.GraphDatabaseSettings; -import org.neo4j.kernel.impl.MyRelTypes; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.ImpermanentDatabaseRule; @@ -37,6 +36,8 @@ import static org.junit.Assert.assertTrue; import static org.neo4j.helpers.collection.Iterables.asArray; import static org.neo4j.kernel.impl.MyRelTypes.TEST; +import static org.neo4j.kernel.impl.MyRelTypes.TEST2; +import static org.neo4j.kernel.impl.MyRelTypes.TEST_TRAVERSAL; /** * Traversing a relationship chain has no consistency guarantees that there will be no change between @@ -67,7 +68,7 @@ public void shouldChaseTheLivingRelationships() throws Exception node = db.createNode(); for ( int i = 0; i < numberOfRelationships; i++ ) { - node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); + node.createRelationshipTo( db.createNode(), TEST ); } tx.success(); } @@ -111,10 +112,10 @@ public void shouldChaseTheLivingRelationshipGroups() throws Exception node = db.createNode(); for ( int i = 0; i < THRESHOLD; i++ ) { - node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); + node.createRelationshipTo( db.createNode(), TEST ); } - relationshipInTheMiddle = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); - relationshipInTheEnd = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST_TRAVERSAL ); + relationshipInTheMiddle = node.createRelationshipTo( db.createNode(), TEST2 ); + relationshipInTheEnd = node.createRelationshipTo( db.createNode(), TEST_TRAVERSAL ); tx.success(); } @@ -125,7 +126,7 @@ public void shouldChaseTheLivingRelationshipGroups() throws Exception Iterator relationships = node.getRelationships().iterator(); for ( int i = 0; i < THRESHOLD / 2; i++ ) { - assertTrue( relationships.next().isType( MyRelTypes.TEST ) ); + assertTrue( relationships.next().isType( TEST ) ); } // Here we're awfully certain that we're on this first group, so we go ahead and delete the @@ -135,7 +136,7 @@ public void shouldChaseTheLivingRelationshipGroups() throws Exception // THEN we should be able to, first of all, iterate through the rest of the relationships of the first type for ( int i = 0; i < THRESHOLD / 2; i++ ) { - assertTrue( relationships.next().isType( MyRelTypes.TEST ) ); + assertTrue( relationships.next().isType( TEST ) ); } // THEN we should be able to see the last relationship, after the deleted one // where the group for the deleted relationship also should've been deleted since it was the diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipGroupStoreTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipGroupStoreTest.java index 770880e1edffd..e952277547551 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipGroupStoreTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/RelationshipGroupStoreTest.java @@ -20,7 +20,6 @@ package org.neo4j.kernel.impl.store; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -119,8 +118,8 @@ public void createDenseNodeWithLowThreshold() node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); assertEquals( 2, node.getDegree() ); - Assert.assertEquals( 1, node.getDegree( MyRelTypes.TEST ) ); - Assert.assertEquals( 1, node.getDegree( MyRelTypes.TEST2 ) ); + assertEquals( 1, node.getDegree( MyRelTypes.TEST ) ); + assertEquals( 1, node.getDegree( MyRelTypes.TEST2 ) ); tx.success(); } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/metatest/TestGraphDescription.java b/community/community-it/kernel-it/src/test/java/org/neo4j/metatest/TestGraphDescription.java index 6dc5b365c3716..e8069bd2ece03 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/metatest/TestGraphDescription.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/metatest/TestGraphDescription.java @@ -20,7 +20,6 @@ package org.neo4j.metatest; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -165,7 +164,7 @@ public void canCreateMoreInvolvedGraphWithPropertiesAndAutoIndex() verifyIKnowYou( "knows", "me" ); try ( Transaction ignored = graphdb.beginTx() ) { - Assert.assertEquals( true, data.get().get( "I" ).getProperty( "bool" ) ); + assertEquals( true, data.get().get( "I" ).getProperty( "bool" ) ); assertFalse( "node autoindex enabled.", graphdb().index().getNodeAutoIndexer().isEnabled() ); try ( IndexHits relationships = graphdb().index() .getRelationshipAutoIndexer().getAutoIndex().get( "name", "relProp" ) ) diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java index 72e77b5125674..52c81ecba59a0 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java @@ -71,7 +71,6 @@ import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; import org.neo4j.kernel.extension.KernelExtensionFactory; import org.neo4j.kernel.impl.MyRelTypes; -import org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper; import org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProviderFactory; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.api.scan.FullStoreChangeStream; @@ -92,7 +91,6 @@ import org.neo4j.storageengine.api.schema.LabelScanReader; import org.neo4j.storageengine.api.schema.SchemaRule; import org.neo4j.test.TestGraphDatabaseFactory; -import org.neo4j.test.mockito.matcher.CollectionMatcher; import org.neo4j.test.rule.PageCacheRule; import org.neo4j.test.rule.TestDirectory; import org.neo4j.test.rule.fs.DefaultFileSystemRule; @@ -129,8 +127,10 @@ import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.helpers.collection.MapUtil.stringMap; import static org.neo4j.kernel.api.index.IndexEntryUpdate.add; +import static org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.singleInstanceIndexProviderFactory; import static org.neo4j.kernel.impl.store.RecordStore.getRecord; import static org.neo4j.kernel.impl.store.record.RecordLoad.NORMAL; +import static org.neo4j.test.mockito.matcher.CollectionMatcher.matchesCollection; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.hasProperty; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.inTx; @@ -915,7 +915,7 @@ public void shouldRunIndexPopulationJobAtShutdown() throws Throwable .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithIndexProvider( - SchemaIndexTestHelper.singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); + singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); inserter.createDeferredSchemaIndex( label( "Hacker" ) ).on( "handle" ).create(); @@ -929,7 +929,7 @@ public void shouldRunIndexPopulationJobAtShutdown() throws Throwable verify( provider ).start(); verify( provider ).getPopulator( any( StoreIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); verify( populator ).create(); - verify( populator ).add( argThat( CollectionMatcher.matchesCollection( add( nodeId, internalIndex.schema(), + verify( populator ).add( argThat( matchesCollection( add( nodeId, internalIndex.schema(), Values.of( "Jakewins" ) ) ) ) ); verify( populator ).verifyDeferredConstraints( any( PropertyAccessor.class ) ); verify( populator ).close( true ); @@ -950,7 +950,7 @@ public void shouldRunConstraintPopulationJobAtShutdown() throws Throwable .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithIndexProvider( - SchemaIndexTestHelper.singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); + singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); inserter.createDeferredConstraint( label( "Hacker" ) ).assertPropertyIsUnique( "handle" ).create(); @@ -964,7 +964,7 @@ public void shouldRunConstraintPopulationJobAtShutdown() throws Throwable verify( provider ).start(); verify( provider ).getPopulator( any( StoreIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); verify( populator ).create(); - verify( populator ).add( argThat( CollectionMatcher.matchesCollection( add( nodeId, internalUniqueIndex.schema(), Values.of( "Jakewins" ) ) ) ) ); + verify( populator ).add( argThat( matchesCollection( add( nodeId, internalUniqueIndex.schema(), Values.of( "Jakewins" ) ) ) ) ); verify( populator ).verifyDeferredConstraints( any( PropertyAccessor.class ) ); verify( populator ).close( true ); verify( provider ).stop(); @@ -986,7 +986,7 @@ public void shouldRepopulatePreexistingIndexed() throws Throwable .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithIndexProvider( - SchemaIndexTestHelper.singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); + singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); long boggle = inserter.createNode( map( "handle", "b0ggl3" ), label( "Hacker" ) ); @@ -998,7 +998,7 @@ public void shouldRepopulatePreexistingIndexed() throws Throwable verify( provider ).start(); verify( provider ).getPopulator( any( StoreIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); verify( populator ).create(); - verify( populator ).add( argThat( CollectionMatcher.matchesCollection( + verify( populator ).add( argThat( matchesCollection( add( jakewins, internalIndex.schema(), Values.of( "Jakewins" ) ), add( boggle, internalIndex.schema(), Values.of( "b0ggl3" ) ) ) ) ); verify( populator ).verifyDeferredConstraints( any( PropertyAccessor.class ) ); @@ -1465,7 +1465,7 @@ private long dbWithIndexAndSingleIndexedNode() throws Exception .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithIndexProvider( - SchemaIndexTestHelper.singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); + singleInstanceIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); inserter.createDeferredSchemaIndex( label("Hacker") ).on( "handle" ).create(); long nodeId = inserter.createNode( map( "handle", "Jakewins" ), label( "Hacker" ) ); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/impl/batchimport/ParallelBatchImporterTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/impl/batchimport/ParallelBatchImporterTest.java index ae0094f14d2e7..f9defbda3494c 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/impl/batchimport/ParallelBatchImporterTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/unsafe/impl/batchimport/ParallelBatchImporterTest.java @@ -69,7 +69,6 @@ import org.neo4j.unsafe.impl.batchimport.input.InputEntityVisitor; import org.neo4j.unsafe.impl.batchimport.input.Inputs; import org.neo4j.unsafe.impl.batchimport.staging.ExecutionMonitor; -import org.neo4j.unsafe.impl.batchimport.staging.ProcessorAssignmentStrategies; import org.neo4j.values.storable.RandomValues; import org.neo4j.values.storable.Values; @@ -90,6 +89,7 @@ import static org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdMappers.strings; import static org.neo4j.unsafe.impl.batchimport.input.Collectors.silentBadCollector; import static org.neo4j.unsafe.impl.batchimport.input.Inputs.knownEstimates; +import static org.neo4j.unsafe.impl.batchimport.staging.ProcessorAssignmentStrategies.eagerRandomSaturation; @RunWith( Parameterized.class ) public class ParallelBatchImporterTest @@ -165,7 +165,7 @@ public ParallelBatchImporterTest( InputIdGenerator inputIdGenerator, Function typeResourceIterator = db.getAllRelationshipTypes().iterator() ) { - Assert.assertEquals( MyRelTypes.TEST.name(), typeResourceIterator.next().name() ); + assertEquals( MyRelTypes.TEST.name(), typeResourceIterator.next().name() ); } finally { diff --git a/community/community-it/kernel-it/src/test/java/recovery/UniquenessRecoveryTest.java b/community/community-it/kernel-it/src/test/java/recovery/UniquenessRecoveryTest.java index 51a12f5c99e07..52c3ec3db539a 100644 --- a/community/community-it/kernel-it/src/test/java/recovery/UniquenessRecoveryTest.java +++ b/community/community-it/kernel-it/src/test/java/recovery/UniquenessRecoveryTest.java @@ -54,6 +54,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeNotNull; import static org.neo4j.graphdb.Label.label; +import static org.neo4j.test.rule.SuppressOutput.suppress; @RunWith( Parameterized.class ) public class UniquenessRecoveryTest @@ -79,7 +80,7 @@ private static String param( String name ) } @Rule - public final SuppressOutput muted = SuppressOutput.suppress( SuppressOutput.System.out ); + public final SuppressOutput muted = suppress( SuppressOutput.System.out ); @Rule public final TestDirectory dir = TestDirectory.testDirectory(); private final Configuration config;