From 1bbb1105a671358c587309b0cfcb38c588028373 Mon Sep 17 00:00:00 2001 From: lutovich Date: Tue, 12 Jul 2016 17:16:42 +0200 Subject: [PATCH] Added MethodParamPad checkstyle rule http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad --- build/checkstyle.xml | 1 + .../messaging/PackStreamMessageFormatV1.java | 2 +- .../full/NodeInUseWithCorrectLabelsCheck.java | 6 +- .../checking/SchemaRecordCheckTest.java | 2 +- .../full/NodeCorrectlyIndexedCheckTest.java | 10 +- .../test/java/cypher/SpecSuiteResources.java | 2 +- .../org/neo4j/tooling/ImportToolTest.java | 2 +- .../java/org/neo4j/test/TraceCounter.java | 97 ------------------- .../graphdb/IndexManagerFacadeMethods.java | 11 +-- .../test/java/org/neo4j/helpers/TestArgs.java | 7 +- .../neo4j/kernel/TestPlaceboTransaction.java | 2 +- .../api/properties/DefinedPropertyTest.java | 2 +- .../impl/api/index/IndexingServiceTest.java | 2 +- .../api/state/SchemaTransactionStateTest.java | 2 +- .../log/BatchingTransactionAppenderTest.java | 2 +- .../server/rest/web/RestfulGraphDatabase.java | 12 +-- .../neo4j/server/rest/RelationshipDocIT.java | 7 +- .../cluster/MultiPaxosServerFactory.java | 4 +- .../StateMachineProxyFactory.java | 5 +- .../context/ClusterContextImplTest.java | 50 +++++----- .../context/HeartbeatContextImplTest.java | 10 +- .../protocol/cluster/ClusterMockTest.java | 3 +- .../heartbeat/HeartbeatContextTest.java | 2 +- ...ighAvailabilityMemberStateMachineTest.java | 2 +- .../HighAvailabilityMemberStateTest.java | 4 +- .../ha/id/HaIdGeneratorFactoryTest.java | 2 +- 26 files changed, 77 insertions(+), 174 deletions(-) delete mode 100644 community/io/src/test/java/org/neo4j/test/TraceCounter.java diff --git a/build/checkstyle.xml b/build/checkstyle.xml index 0e1cd1ab8c29..a860ac9e7907 100644 --- a/build/checkstyle.xml +++ b/build/checkstyle.xml @@ -52,6 +52,7 @@ + diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PackStreamMessageFormatV1.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PackStreamMessageFormatV1.java index 4defb85131fb..e518cb0654b4 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PackStreamMessageFormatV1.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/messaging/PackStreamMessageFormatV1.java @@ -274,7 +274,7 @@ public void read( MessageHandler output ) throws IOExce catch( PackStream.PackStreamException e ) { throw new BoltIOException( Status.Request.InvalidFormat, - "Unable to read " + messageTypeName (type) + " message. " + + "Unable to read " + messageTypeName( type ) + " message. " + "Error was: " + e.getMessage(), e ); } } diff --git a/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/NodeInUseWithCorrectLabelsCheck.java b/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/NodeInUseWithCorrectLabelsCheck.java index 783329637b6c..1aa1cdcb38ae 100644 --- a/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/NodeInUseWithCorrectLabelsCheck.java +++ b/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/NodeInUseWithCorrectLabelsCheck.java @@ -58,9 +58,9 @@ public void checkReference( RECORD record, NodeRecord nodeRecord, DynamicNodeLabels dynamicNodeLabels = (DynamicNodeLabels) nodeLabels; long firstRecordId = dynamicNodeLabels.getFirstDynamicRecordId(); RecordReference firstRecordReference = records.nodeLabels( firstRecordId ); - engine.comparativeCheck( firstRecordReference, - new LabelChainWalker - (new ExpectedNodeLabelsChecker( nodeRecord )) ); + ExpectedNodeLabelsChecker expectedNodeLabelsChecker = new ExpectedNodeLabelsChecker( nodeRecord ); + LabelChainWalker checker = new LabelChainWalker<>( expectedNodeLabelsChecker ); + engine.comparativeCheck( firstRecordReference, checker ); nodeRecord.getDynamicLabelRecords(); // I think this is empty in production } else diff --git a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java index a08b200d0f47..4821e42c73c2 100644 --- a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java +++ b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/SchemaRecordCheckTest.java @@ -81,7 +81,7 @@ public void shouldReportInvalidLabelReferences() throws Exception IndexRule rule = IndexRule.indexRule( schemaRuleId, labelId, propertyKeyId, providerDescriptor ); when( checker().ruleAccess.loadSingleSchemaRule( schemaRuleId ) ).thenReturn( rule ); - LabelTokenRecord labelTokenRecord = add ( notInUse( new LabelTokenRecord( labelId ) ) ); + LabelTokenRecord labelTokenRecord = add( notInUse( new LabelTokenRecord( labelId ) ) ); add(inUse( new PropertyKeyTokenRecord( propertyKeyId ) ) ); // when diff --git a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/NodeCorrectlyIndexedCheckTest.java b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/NodeCorrectlyIndexedCheckTest.java index e831994bda87..d044da1e99d5 100644 --- a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/NodeCorrectlyIndexedCheckTest.java +++ b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/NodeCorrectlyIndexedCheckTest.java @@ -48,14 +48,12 @@ import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.IndexSampler; +import static java.util.Arrays.asList; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; - -import static java.util.Arrays.asList; - import static org.neo4j.collection.primitive.PrimitiveLongCollections.emptyIterator; import static org.neo4j.kernel.api.properties.Property.stringProperty; import static org.neo4j.kernel.impl.store.record.IndexRule.constraintIndexRule; @@ -160,10 +158,8 @@ private IndexAccessors indexContaining( IndexRule indexRule, Map { IndexAccessorStub reader = new IndexAccessorStub( entries ); IndexAccessors indexes = mock( IndexAccessors.class ); - when( indexes.accessorFor( any( IndexRule.class ) ) ) - .thenReturn( reader ); - when (indexes.rules() ) - .thenReturn( asList(indexRule) ); + when( indexes.accessorFor( any( IndexRule.class ) ) ).thenReturn( reader ); + when( indexes.rules() ).thenReturn( asList( indexRule ) ); return indexes; } diff --git a/community/cypher/spec-suite-tools/src/test/java/cypher/SpecSuiteResources.java b/community/cypher/spec-suite-tools/src/test/java/cypher/SpecSuiteResources.java index d07f65dd524a..db96c0442850 100644 --- a/community/cypher/spec-suite-tools/src/test/java/cypher/SpecSuiteResources.java +++ b/community/cypher/spec-suite-tools/src/test/java/cypher/SpecSuiteResources.java @@ -141,7 +141,7 @@ public static File targetDirectory( Class klass, String suffix ) private static File obtainTargetDirectory( boolean create, String specSuiteName, String suffix ) { - File directory = new File( new File ( new File( "target" ), specSuiteName ), suffix ).getAbsoluteFile(); + File directory = new File( new File( new File( "target" ), specSuiteName ), suffix ).getAbsoluteFile(); if ( !directory.exists() ) { if ( !(create && directory.mkdirs()) ) diff --git a/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java b/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java index fdf42006a954..b903f60636db 100644 --- a/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java +++ b/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java @@ -196,7 +196,7 @@ public void import4097Labels() throws Exception tx.success(); ResourceIterator nodes = dbRule.findNodes( DynamicLabel.label( "FIRST 4096" ) ); - assertEquals (1, Iterators.asList(nodes).size() ); + assertEquals( 1, Iterators.asList( nodes ).size() ); nodes = dbRule.findNodes( DynamicLabel.label( "SECOND 4096" ) ); assertEquals( 1, Iterators.asList( nodes ).size() ); } diff --git a/community/io/src/test/java/org/neo4j/test/TraceCounter.java b/community/io/src/test/java/org/neo4j/test/TraceCounter.java deleted file mode 100644 index 701552c01c81..000000000000 --- a/community/io/src/test/java/org/neo4j/test/TraceCounter.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2002-2016 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.test; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * When debugging it can sometimes be useful to know from where a method is being called, and how often. - * Set a breakpoint in that method and evaluate an expression that calls {@link #trace(String)}. Before the test case - * ends, set another breakpoint that suspends the VM and call asString() to get printouts of all ways in which the method - * was invoked. - */ -public class TraceCounter -{ - private static Map, AtomicInteger>> traceCounts = new HashMap<>( ); - - public static String trace(String name) - { - Map, AtomicInteger> namedTraces = traceCounts.get( name ); - - if (namedTraces == null) - { - namedTraces = new HashMap<>( ); - traceCounts.put(name, namedTraces); - } - - List trace = Arrays.asList(new Exception().getStackTrace()); - - AtomicInteger count = namedTraces.get(trace); - if (count == null) - { - count = new AtomicInteger( ); - namedTraces.put(trace, count); - } - - count.incrementAndGet(); - - return ""; - } - - public static void clear() - { - traceCounts.clear(); - } - - public static void print(PrintWriter out) - { - for ( Map.Entry, AtomicInteger>> stringMapEntry : traceCounts.entrySet() ) - { - out.println(stringMapEntry.getKey()); - for ( Map.Entry, AtomicInteger> listAtomicIntegerEntry : stringMapEntry.getValue - ().entrySet() ) - { - out.println(listAtomicIntegerEntry.getValue().get()+":"); - for ( StackTraceElement stackTraceElement : listAtomicIntegerEntry.getKey() ) - { - out.println(stackTraceElement); - } - out.println(); - } - - out.println("---------------------------------"); - } - } - - public static String asString() - { - StringWriter writer = new StringWriter( ); - PrintWriter print = new PrintWriter( writer ); - print(print); - print.close(); - return writer.toString(); - } -} diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/IndexManagerFacadeMethods.java b/community/kernel/src/test/java/org/neo4j/graphdb/IndexManagerFacadeMethods.java index 14f025a44469..9b425aeab40c 100644 --- a/community/kernel/src/test/java/org/neo4j/graphdb/IndexManagerFacadeMethods.java +++ b/community/kernel/src/test/java/org/neo4j/graphdb/IndexManagerFacadeMethods.java @@ -46,7 +46,7 @@ public void call( IndexManager indexManager ) } }; - private static final FacadeMethod FOR_NODES_WITH_CONFIGURATION = new FacadeMethod( + private static final FacadeMethod FOR_NODES_WITH_CONFIG = new FacadeMethod( "Index forNodes( String indexName, Map customConfiguration )" ) { @Override @@ -89,9 +89,8 @@ public void call( IndexManager indexManager ) } }; - private static final FacadeMethod FOR_RELATIONSHIPS_WITH_CONFIGURATION = new - FacadeMethod - ( "RelationshipIndex forRelationships( String indexName, Map customConfiguration )" ) + private static final FacadeMethod FOR_RELATIONSHIPS_WITH_CONFIG = new FacadeMethod( + "RelationshipIndex forRelationships( String indexName, Map customConfiguration )" ) { @Override public void call( IndexManager indexManager ) @@ -117,11 +116,11 @@ public void call( IndexManager indexManager ) unmodifiableCollection( asList( EXISTS_FOR_NODES, FOR_NODES, - FOR_NODES_WITH_CONFIGURATION, + FOR_NODES_WITH_CONFIG, NODE_INDEX_NAMES, EXISTS_FOR_RELATIONSHIPS, FOR_RELATIONSHIPS, - FOR_RELATIONSHIPS_WITH_CONFIGURATION, + FOR_RELATIONSHIPS_WITH_CONFIG, RELATIONSHIP_INDEX_NAMES ) ); } diff --git a/community/kernel/src/test/java/org/neo4j/helpers/TestArgs.java b/community/kernel/src/test/java/org/neo4j/helpers/TestArgs.java index 9041a21c966f..179d8277cf38 100644 --- a/community/kernel/src/test/java/org/neo4j/helpers/TestArgs.java +++ b/community/kernel/src/test/java/org/neo4j/helpers/TestArgs.java @@ -19,6 +19,8 @@ */ package org.neo4j.helpers; +import org.junit.Test; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -27,8 +29,6 @@ import java.util.List; import java.util.Map; -import org.junit.Test; - import org.neo4j.helpers.Args.Option; import org.neo4j.kernel.impl.util.Converters; import org.neo4j.kernel.impl.util.Validator; @@ -41,7 +41,6 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; - import static org.neo4j.helpers.collection.MapUtil.stringMap; public class TestArgs @@ -80,7 +79,7 @@ public void testParameterWithDashValue() String [] line = { "-file", "-" }; Args args = Args.parse( line ); assertEquals( 1, args.asMap().size() ); - assertEquals( "-", args.get ( "file", null ) ); + assertEquals( "-", args.get( "file", null ) ); assertTrue( args.orphans().isEmpty() ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/TestPlaceboTransaction.java b/community/kernel/src/test/java/org/neo4j/kernel/TestPlaceboTransaction.java index 572114e444cc..0af9290a17af 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/TestPlaceboTransaction.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/TestPlaceboTransaction.java @@ -47,7 +47,7 @@ public class TestPlaceboTransaction @Before public void before() throws Exception { - ThreadToStatementContextBridge bridge = mock (ThreadToStatementContextBridge.class ); + ThreadToStatementContextBridge bridge = mock( ThreadToStatementContextBridge.class ); when( bridge.get() ).thenReturn( mock( Statement.class ) ); kernelTransaction = spy( KernelTransaction.class ); Statement statement = mock( Statement.class ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/properties/DefinedPropertyTest.java b/community/kernel/src/test/java/org/neo4j/kernel/api/properties/DefinedPropertyTest.java index e35776a2420c..df78619e7092 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/properties/DefinedPropertyTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/properties/DefinedPropertyTest.java @@ -170,7 +170,7 @@ private int compare( DefinedProperty leftProperty, DefinedProperty rightProperty { int leftComparison = DefinedProperty.COMPARATOR.compare( leftProperty, rightProperty ); int rightComparison = DefinedProperty.COMPARATOR.compare( rightProperty, leftProperty ); - assertThat( sign ( leftComparison ) , equalTo( -sign( rightComparison ) ) ); + assertThat( sign( leftComparison ), equalTo( -sign( rightComparison ) ) ); return leftComparison; } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java index 06cf2825dd26..106af9625d62 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java @@ -241,7 +241,7 @@ public void shouldDeliverUpdatesThatOccurDuringPopulationToPopulator() throws Ex InOrder order = inOrder( populator, accessor, updater); order.verify( populator ).create(); order.verify( populator ).includeSample( add( 1, "value1" ) ); - order.verify( populator ).add( Mockito.anyListOf (NodePropertyUpdate.class)); + order.verify( populator ).add( Mockito.anyListOf( NodePropertyUpdate.class ) ); // invoked from indexAllNodes(), empty because the id we added (2) is bigger than the one we indexed (1) // diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java index a84a30a4ab0e..e51ef4276661 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/SchemaTransactionStateTest.java @@ -227,7 +227,7 @@ public void before() throws Exception mock( ConstraintIndexCreator.class ), mock( LegacyIndexStore.class ) ); storeStatement = mock(StoreStatement.class); - when (state.getStoreStatement()).thenReturn( storeStatement ); + when( state.getStoreStatement() ).thenReturn( storeStatement ); } private static Answer> asAnswer( final Iterable values ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/BatchingTransactionAppenderTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/BatchingTransactionAppenderTest.java index 642e3c43126a..f59558c0a93a 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/BatchingTransactionAppenderTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/BatchingTransactionAppenderTest.java @@ -332,7 +332,7 @@ public void shouldKernelPanicIfNotAbleToWriteACheckPoint() throws Throwable // Given IOException ioex = new IOException( "boom!" ); FlushablePositionAwareChannel channel = mock( FlushablePositionAwareChannel.class, RETURNS_MOCKS ); - when (channel.put( anyByte() ) ).thenReturn( channel ); + when( channel.put( anyByte() ) ).thenReturn( channel ); when( channel.putLong( anyLong() ) ).thenThrow( ioex ); when( channel.put( anyByte() ) ).thenThrow( ioex ); when( logFile.getWriter() ).thenReturn( channel ); diff --git a/community/server/src/main/java/org/neo4j/server/rest/web/RestfulGraphDatabase.java b/community/server/src/main/java/org/neo4j/server/rest/web/RestfulGraphDatabase.java index 81e72b9f67dc..404062d09700 100644 --- a/community/server/src/main/java/org/neo4j/server/rest/web/RestfulGraphDatabase.java +++ b/community/server/src/main/java/org/neo4j/server/rest/web/RestfulGraphDatabase.java @@ -1009,8 +1009,8 @@ public Response addToNodeIndex( @PathParam("indexName") String indexName, @Query String.valueOf( entityBody.get( "key" ) ), getOrCreateValue, extractNodeIdOrNull( getStringOrNull( entityBody, "uri" ) ), getMapOrNull( entityBody, "properties" ) ); - return result.other() ? output.created( result.first() ) : output.okIncludeLocation( result.first - () ); + return result.other() ? output.created( result.first() ) + : output.okIncludeLocation( result.first() ); case CreateOrFail: entityBody = input.readMap( postBody, "key", "value" ); @@ -1107,8 +1107,8 @@ public Response addToRelationshipIndex( @PathParam("indexName") String indexName entityBody = input.readMap( postBody, "key", "value" ); result = actions.getOrCreateIndexedRelationship( indexName, String.valueOf( entityBody.get( "key" ) ), - String.valueOf( entityBody.get( "value" ) ), extractRelationshipIdOrNull( getStringOrNull - ( entityBody, "uri" ) ), + String.valueOf( entityBody.get( "value" ) ), + extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ), extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ), getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody, "end" ) ), @@ -1119,8 +1119,8 @@ public Response addToRelationshipIndex( @PathParam("indexName") String indexName entityBody = input.readMap( postBody, "key", "value" ); result = actions.getOrCreateIndexedRelationship( indexName, String.valueOf( entityBody.get( "key" ) ), - String.valueOf( entityBody.get( "value" ) ), extractRelationshipIdOrNull( getStringOrNull - ( entityBody, "uri" ) ), + String.valueOf( entityBody.get( "value" ) ), + extractRelationshipIdOrNull( getStringOrNull( entityBody, "uri" ) ), extractNodeIdOrNull( getStringOrNull( entityBody, "start" ) ), getStringOrNull( entityBody, "type" ), extractNodeIdOrNull( getStringOrNull( entityBody, "end" ) ), diff --git a/community/server/src/test/java/org/neo4j/server/rest/RelationshipDocIT.java b/community/server/src/test/java/org/neo4j/server/rest/RelationshipDocIT.java index bd5e1935842a..10cc200c91b7 100644 --- a/community/server/src/test/java/org/neo4j/server/rest/RelationshipDocIT.java +++ b/community/server/src/test/java/org/neo4j/server/rest/RelationshipDocIT.java @@ -135,9 +135,10 @@ public void shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationshipS { data.get(); Relationship loves = getFirstRelationshipFromRomeoNode(); - gen().withHeader( StreamingFormat.STREAM_HEADER, "true" ).expectedStatus( Status.NOT_FOUND.getStatusCode - () ).delete( - getPropertiesUri( loves ) + "/non-existent" ).entity(); + gen().withHeader( StreamingFormat.STREAM_HEADER, "true" ) + .expectedStatus( Status.NOT_FOUND.getStatusCode() ) + .delete( getPropertiesUri( loves ) + "/non-existent" ) + .entity(); } @Test diff --git a/enterprise/cluster/src/main/java/org/neo4j/cluster/MultiPaxosServerFactory.java b/enterprise/cluster/src/main/java/org/neo4j/cluster/MultiPaxosServerFactory.java index a33f2290ef55..477aabdd10f6 100644 --- a/enterprise/cluster/src/main/java/org/neo4j/cluster/MultiPaxosServerFactory.java +++ b/enterprise/cluster/src/main/java/org/neo4j/cluster/MultiPaxosServerFactory.java @@ -168,8 +168,8 @@ public void listeningAt( URI me ) } } ); - stateMachines.addMessageProcessor( new HeartbeatRefreshProcessor( stateMachines.getOutgoing - (), context.getClusterContext() ) ); + stateMachines.addMessageProcessor( new HeartbeatRefreshProcessor( stateMachines.getOutgoing(), + context.getClusterContext() ) ); input.addMessageProcessor( new HeartbeatIAmAliveProcessor( stateMachines.getOutgoing(), context.getClusterContext() ) ); diff --git a/enterprise/cluster/src/main/java/org/neo4j/cluster/statemachine/StateMachineProxyFactory.java b/enterprise/cluster/src/main/java/org/neo4j/cluster/statemachine/StateMachineProxyFactory.java index b546d9adf3f2..9216b6fa8bac 100644 --- a/enterprise/cluster/src/main/java/org/neo4j/cluster/statemachine/StateMachineProxyFactory.java +++ b/enterprise/cluster/src/main/java/org/neo4j/cluster/statemachine/StateMachineProxyFactory.java @@ -167,8 +167,9 @@ private StateMachine getStateMachine( Class proxyInterface ) if ( foundMatch ) // State machine could only partially handle this interface { - exception = new IllegalArgumentException( "State machine for " + stateMachine.getMessageType - ().getName() + " cannot handle method:" + method.getName() ); + exception = new IllegalArgumentException( + "State machine for " + stateMachine.getMessageType().getName() + + " cannot handle method:" + method.getName() ); } // Continue searching diff --git a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/ClusterContextImplTest.java b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/ClusterContextImplTest.java index 3ecf8a4e7e4f..0e2f86ab8196 100644 --- a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/ClusterContextImplTest.java +++ b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/ClusterContextImplTest.java @@ -19,12 +19,12 @@ */ package org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context; -import java.net.URI; -import java.util.concurrent.Executor; - import org.junit.Test; import org.mockito.ArgumentCaptor; +import java.net.URI; +import java.util.concurrent.Executor; + import org.neo4j.cluster.InstanceId; import org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory; import org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory; @@ -61,9 +61,10 @@ public void electorLeavingTheClusterMustBeRemovedAsElector() throws Throwable CommonContextState commonContextState = mock( CommonContextState.class ); when( commonContextState.configuration() ).thenReturn( clusterConfiguration ); - ClusterContext context = new ClusterContextImpl(me, commonContextState, NullLogProvider.getInstance(), - mock( Timeouts.class ), mock ( Executor.class ), mock( ObjectOutputStreamFactory.class ), mock( - ObjectInputStreamFactory.class ), mock( LearnerContext.class ), mock( HeartbeatContext.class ) ); + ClusterContext context = new ClusterContextImpl( me, commonContextState, NullLogProvider.getInstance(), + mock( Timeouts.class ), mock( Executor.class ), mock( ObjectOutputStreamFactory.class ), + mock( ObjectInputStreamFactory.class ), mock( LearnerContext.class ), + mock( HeartbeatContext.class ) ); // This means instance 2 was the elector at version 8 context.setLastElector( elector ); @@ -95,9 +96,10 @@ public void nonElectorLeavingTheClusterMustNotAffectElectorInformation() throws CommonContextState commonContextState = mock( CommonContextState.class ); when( commonContextState.configuration() ).thenReturn( clusterConfiguration ); - ClusterContext context = new ClusterContextImpl(me, commonContextState, NullLogProvider.getInstance(), - mock( Timeouts.class ), mock ( Executor.class ), mock( ObjectOutputStreamFactory.class ), mock( - ObjectInputStreamFactory.class ), mock( LearnerContext.class ), mock( HeartbeatContext.class ) ); + ClusterContext context = new ClusterContextImpl( me, commonContextState, NullLogProvider.getInstance(), + mock( Timeouts.class ), mock( Executor.class ), mock( ObjectOutputStreamFactory.class ), + mock( ObjectInputStreamFactory.class ), mock( LearnerContext.class ), + mock( HeartbeatContext.class ) ); // This means instance 2 was the elector at version 8 context.setLastElector( elector ); @@ -125,9 +127,10 @@ public void instanceEnteringTheClusterMustBeRemovedAsElector() throws Exception CommonContextState commonContextState = mock( CommonContextState.class, RETURNS_MOCKS ); - ClusterContext context = new ClusterContextImpl(me, commonContextState, NullLogProvider.getInstance(), - mock( Timeouts.class ), mock ( Executor.class ), mock( ObjectOutputStreamFactory.class ), mock( - ObjectInputStreamFactory.class ), mock( LearnerContext.class ), mock( HeartbeatContext.class ) ); + ClusterContext context = new ClusterContextImpl( me, commonContextState, NullLogProvider.getInstance(), + mock( Timeouts.class ), mock( Executor.class ), mock( ObjectOutputStreamFactory.class ), + mock( ObjectInputStreamFactory.class ), mock( LearnerContext.class ), + mock( HeartbeatContext.class ) ); // This means instance 2 was the elector at version 8 context.setLastElector( elector ); @@ -155,9 +158,10 @@ public void instanceEnteringTheClusterMustBeNotAffectElectorStatusIfItWasNotElec CommonContextState commonContextState = mock( CommonContextState.class, RETURNS_MOCKS ); - ClusterContext context = new ClusterContextImpl(me, commonContextState, NullLogProvider.getInstance(), - mock( Timeouts.class ), mock ( Executor.class ), mock( ObjectOutputStreamFactory.class ), mock( - ObjectInputStreamFactory.class ), mock( LearnerContext.class ), mock( HeartbeatContext.class ) ); + ClusterContext context = new ClusterContextImpl( me, commonContextState, NullLogProvider.getInstance(), + mock( Timeouts.class ), mock( Executor.class ), mock( ObjectOutputStreamFactory.class ), + mock( ObjectInputStreamFactory.class ), mock( LearnerContext.class ), + mock( HeartbeatContext.class ) ); // This means instance 2 was the elector at version 8 context.setLastElector( elector ); @@ -186,13 +190,13 @@ public void electorFailingMustCauseElectorVersionToBeReset() throws Exception Timeouts timeouts = mock( Timeouts.class ); Executor executor = mock( Executor.class ); - HeartbeatContext heartbeatContext = mock ( HeartbeatContext.class ); + HeartbeatContext heartbeatContext = mock( HeartbeatContext.class ); ArgumentCaptor listenerCaptor = ArgumentCaptor.forClass( HeartbeatListener.class ); - ClusterContext context = new ClusterContextImpl(me, commonContextState, NullLogProvider.getInstance(), - timeouts, executor, mock( ObjectOutputStreamFactory.class ), mock( - ObjectInputStreamFactory.class ), mock( LearnerContext.class ), heartbeatContext ); + ClusterContext context = new ClusterContextImpl( me, commonContextState, NullLogProvider.getInstance(), + timeouts, executor, mock( ObjectOutputStreamFactory.class ), mock( ObjectInputStreamFactory.class ), + mock( LearnerContext.class ), heartbeatContext ); verify( heartbeatContext ).addHeartbeatListener( listenerCaptor.capture() ); @@ -225,13 +229,13 @@ public void nonElectorFailingMustNotCauseElectorVersionToBeReset() throws Except Timeouts timeouts = mock( Timeouts.class ); Executor executor = mock( Executor.class ); - HeartbeatContext heartbeatContext = mock ( HeartbeatContext.class ); + HeartbeatContext heartbeatContext = mock( HeartbeatContext.class ); ArgumentCaptor listenerCaptor = ArgumentCaptor.forClass( HeartbeatListener.class ); - ClusterContext context = new ClusterContextImpl(me, commonContextState, NullLogProvider.getInstance(), - timeouts, executor, mock( ObjectOutputStreamFactory.class ), mock( - ObjectInputStreamFactory.class ), mock( LearnerContext.class ), heartbeatContext ); + ClusterContext context = new ClusterContextImpl( me, commonContextState, NullLogProvider.getInstance(), + timeouts, executor, mock( ObjectOutputStreamFactory.class ), mock( ObjectInputStreamFactory.class ), + mock( LearnerContext.class ), heartbeatContext ); verify( heartbeatContext ).addHeartbeatListener( listenerCaptor.capture() ); diff --git a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/HeartbeatContextImplTest.java b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/HeartbeatContextImplTest.java index ded5c0183925..35916af6d238 100644 --- a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/HeartbeatContextImplTest.java +++ b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/context/HeartbeatContextImplTest.java @@ -19,13 +19,13 @@ */ package org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context; +import org.junit.Test; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Test; - import org.neo4j.cluster.DelayedDirectExecutor; import org.neo4j.cluster.InstanceId; import org.neo4j.cluster.protocol.cluster.ClusterConfiguration; @@ -55,7 +55,7 @@ public void shouldFailAndAliveBothNotifyHeartbeatListenerInDelayedDirectExecutor Timeouts timeouts = mock( Timeouts.class ); CommonContextState commonState = mock( CommonContextState.class ); - ClusterConfiguration configuration = mock (ClusterConfiguration.class); + ClusterConfiguration configuration = mock( ClusterConfiguration.class ); when( commonState.configuration() ).thenReturn( configuration ); when( configuration.getMembers() ).thenReturn( members( 3 ) ); when( configuration.getMemberIds() ).thenReturn( ids( 3 ) ); @@ -92,7 +92,7 @@ public void shouldFailAllInstancesIfAllOtherInstancesAreSuspected() throws Excep Timeouts timeouts = mock( Timeouts.class ); CommonContextState commonState = mock( CommonContextState.class ); - ClusterConfiguration configuration = mock ( ClusterConfiguration.class ); + ClusterConfiguration configuration = mock( ClusterConfiguration.class ); when( commonState.configuration() ).thenReturn( configuration ); when( configuration.getMembers() ).thenReturn( members( 3 ) ); when( configuration.getMemberIds() ).thenReturn( ids( 3 ) ); @@ -161,7 +161,7 @@ public void majorityOfNonSuspectedInstancesShouldBeEnoughToMarkAnInstanceAsFaile Timeouts timeouts = mock( Timeouts.class ); CommonContextState commonState = mock( CommonContextState.class ); - ClusterConfiguration configuration = mock ( ClusterConfiguration.class ); + ClusterConfiguration configuration = mock( ClusterConfiguration.class ); when( commonState.configuration() ).thenReturn( configuration ); when( configuration.getMembers() ).thenReturn( members( 5 ) ); when( configuration.getMemberIds() ).thenReturn( ids( 5 ) ); diff --git a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/cluster/ClusterMockTest.java b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/cluster/ClusterMockTest.java index 5dbe786399e4..361c47cb5507 100644 --- a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/cluster/ClusterMockTest.java +++ b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/cluster/ClusterMockTest.java @@ -426,8 +426,7 @@ private void verifyConfigurations( StateMachines stateMachines, List member } try { - assertEquals( "Failed for server" + myId + " is wrong", failed, heartbeatContext.getFailed - () ); + assertEquals( "Failed for server" + myId + " is wrong", failed, heartbeatContext.getFailed() ); } catch ( AssertionError e ) { diff --git a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/heartbeat/HeartbeatContextTest.java b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/heartbeat/HeartbeatContextTest.java index b4ec5e892c7b..8b2ff2770f55 100644 --- a/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/heartbeat/HeartbeatContextTest.java +++ b/enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/heartbeat/HeartbeatContextTest.java @@ -228,7 +228,7 @@ public void shouldConsultSuspicionsOnlyFromCurrentClusterMembers() throws Except toTest.suspicions( notInCluster, Iterables.asSet( Iterables.iterable( instanceIds[1] ) ) ); // When - List suspicions = toTest.getSuspicionsOf ( instanceIds[1] ); + List suspicions = toTest.getSuspicionsOf( instanceIds[1] ); // Then assertThat( suspicions.size(), CoreMatchers.equalTo( 0 ) ); diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java index 4d244baac63d..88782ca66af0 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateMachineTest.java @@ -631,7 +631,7 @@ private HighAvailabilityMemberStateMachine buildMockedStateMachine() return new StateMachineBuilder().build(); } - private HighAvailabilityMemberStateMachine buildMockedStateMachine ( HighAvailabilityMemberContext context, + private HighAvailabilityMemberStateMachine buildMockedStateMachine( HighAvailabilityMemberContext context, ClusterMemberEvents events ) { return new StateMachineBuilder().withContext( context ).withEvents( events ).build(); diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateTest.java index 4fb9237d48d0..ce5d29aa5b87 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityMemberStateTest.java @@ -196,8 +196,8 @@ public void testToSlaveMasterIsAvailable() assertEquals( TO_SLAVE, newState ); // CASE 3: Got MasterIsAvailable for someone else who is not the master - should fail - HighAvailabilityMemberState moreIllegal = TO_SLAVE.masterIsAvailable( context, new InstanceId - ( 3 ), SampleUri ); + InstanceId instanceId = new InstanceId( 3 ); + HighAvailabilityMemberState moreIllegal = TO_SLAVE.masterIsAvailable( context, instanceId, SampleUri ); assertEquals( ILLEGAL, moreIllegal ); } diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/id/HaIdGeneratorFactoryTest.java b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/id/HaIdGeneratorFactoryTest.java index 6116f13bdb4d..562fc7fb22e1 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/ha/id/HaIdGeneratorFactoryTest.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/ha/id/HaIdGeneratorFactoryTest.java @@ -159,7 +159,7 @@ public void slaveShouldNeverAllowReducingHighId() throws Exception gen.nextId(); // that will ask the master for an IdRange // THEN - assertEquals ( highIdFromUpdatedRecord, gen.getHighId() ); + assertEquals( highIdFromUpdatedRecord, gen.getHighId() ); } @Test