private Callable <Void> SharedClientStarter(CoreTopologyService topologyService, ISet <MemberId> expectedTargetSet) { return(() => { try { RaftMachine raftMock = mock(typeof(RaftMachine)); RaftCoreTopologyConnector tc = new RaftCoreTopologyConnector(topologyService, raftMock, CausalClusteringSettings.database.DefaultValue); topologyService.init(); topologyService.start(); tc.start(); assertEventually("should discover complete target set", () => { ArgumentCaptor <ISet <MemberId> > targetMembers = ArgumentCaptor.forClass((Type <ISet <MemberId> >)expectedTargetSet.GetType()); verify(raftMock, atLeastOnce()).TargetMembershipSet = targetMembers.capture(); return targetMembers.Value; }, equalTo(expectedTargetSet), TIMEOUT_MS, MILLISECONDS); } catch (Exception throwable) { fail(throwable.Message); } return null; }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldResumeWhenWritabilityChanged() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldResumeWhenWritabilityChanged() { TestThrottleLock lockOverride = new TestThrottleLock(); // given TransportThrottle throttle = NewThrottleAndInstall(_channel, lockOverride); when(_channel.Writable).thenReturn(false); Future <Void> completionFuture = OtherThread.execute(state => { throttle.Acquire(_channel); return(null); }); OtherThread.get().waitUntilWaiting(); // when when(_channel.Writable).thenReturn(true); ArgumentCaptor <ChannelInboundHandler> captor = ArgumentCaptor.forClass(typeof(ChannelInboundHandler)); verify(_channel.pipeline()).addLast(captor.capture()); captor.Value.channelWritabilityChanged(_context); OtherThread.get().awaitFuture(completionFuture); assertThat(lockOverride.LockCallCount(), greaterThan(0)); assertThat(lockOverride.UnlockCallCount(), @is(1)); }
private static void AssertMessageHexDumpLogged(Log logMock, sbyte[] messageBytes) { ArgumentCaptor <string> captor = ArgumentCaptor.forClass(typeof(string)); verify(logMock).error(captor.capture()); assertThat(captor.Value, containsString(hexDump(messageBytes))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldClearSlavesWhenNewMasterElected() public virtual void ShouldClearSlavesWhenNewMasterElected() { // given Cluster cluster = mock(typeof(Cluster)); ClusterMembers clusterMembers = mock(typeof(ClusterMembers)); when(clusterMembers.AliveMembers).thenReturn(Iterables.option((new ClusterMember(_instanceId)).availableAs(SLAVE, _haUri, StoreId.DEFAULT))); SlaveFactory slaveFactory = mock(typeof(SlaveFactory)); Slave slave1 = mock(typeof(Slave)); Slave slave2 = mock(typeof(Slave)); when(slaveFactory.NewSlave(any(typeof(LifeSupport)), any(typeof(ClusterMember)), any(typeof(string)), any(typeof(Integer)))).thenReturn(slave1, slave2); HighAvailabilitySlaves slaves = new HighAvailabilitySlaves(clusterMembers, cluster, slaveFactory, new HostnamePort("localhost", 0)); slaves.Init(); ArgumentCaptor <ClusterListener> listener = ArgumentCaptor.forClass(typeof(ClusterListener)); verify(cluster).addClusterListener(listener.capture()); // when Slave actualSlave1 = slaves.Slaves.GetEnumerator().next(); listener.Value.elected(ClusterConfiguration.COORDINATOR, _instanceId, _clusterUri); Slave actualSlave2 = slaves.Slaves.GetEnumerator().next(); // then assertThat(actualSlave2, not(sameInstance(actualSlave1))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyVerifyUniqueness(org.neo4j.kernel.api.impl.schema.SchemaIndex index, org.neo4j.internal.kernel.api.schema.SchemaDescriptor descriptor, Object... values) throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException private void VerifyVerifyUniqueness(SchemaIndex index, SchemaDescriptor descriptor, params object[] values) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.mockito.ArgumentCaptor<java.util.List<org.neo4j.values.storable.Value[]>> captor = org.mockito.ArgumentCaptor.forClass(java.util.List.class); ArgumentCaptor <IList <Value[]> > captor = ArgumentCaptor.forClass(typeof(System.Collections.IList)); verify(index).verifyUniqueness(any(), eq(descriptor.PropertyIds), captor.capture()); assertThat(captor.Value, containsInAnyOrder(valueTupleList(values).toArray())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldResumeAsyncResponseDueToTooManyRequests() public virtual void shouldResumeAsyncResponseDueToTooManyRequests() { // given // when AsyncResponse asyncResponse = mock(typeof(AsyncResponse)); handler.errorTooManyRequests(asyncResponse); // then ArgumentCaptor <InvalidRequestException> argumentCaptor = ArgumentCaptor.forClass(typeof(InvalidRequestException)); verify(asyncResponse).resume(argumentCaptor.capture()); assertThat(argumentCaptor.Value.Message, @is("At the moment the server has to handle too " + "many requests at the same time. Please try again later.")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void databasePanicIsRaisedWhenTxApplicationFails() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DatabasePanicIsRaisedWhenTxApplicationFails() { RecordStorageEngine engine = BuildRecordStorageEngine(); Exception applicationError = ExecuteFailingTransaction(engine); ArgumentCaptor <Exception> captor = ArgumentCaptor.forClass(typeof(Exception)); verify(_databaseHealth).panic(captor.capture()); Exception exception = captor.Value; if (exception is KernelException) { assertThat((( KernelException )exception).status(), @is(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError)); exception = exception.InnerException; } assertThat(exception, @is(applicationError)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void appliesDefaultTuningConfigurationForConsistencyChecker() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AppliesDefaultTuningConfigurationForConsistencyChecker() { // given string[] args = new string[] { "-host", "localhost", "-to", "my_backup" }; BackupProtocolService service = mock(typeof(BackupProtocolService)); PrintStream systemOut = mock(typeof(PrintStream)); // when (new BackupTool(service, systemOut)).Run(args); // then ArgumentCaptor <Config> config = ArgumentCaptor.forClass(typeof(Config)); verify(service).doIncrementalBackupOrFallbackToFull(anyString(), anyInt(), eq(DatabaseLayout.of(Paths.get("my_backup").toFile())), any(typeof(ConsistencyCheck)), config.capture(), eq(BackupClient.BIG_READ_TIMEOUT), eq(false)); assertFalse(config.Value.get(ConsistencyCheckSettings.consistency_check_property_owners)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Ignore @Test public void shouldSetAuthenticationProperly() public virtual void shouldSetAuthenticationProperly() { when(identityServiceMock.CurrentAuthentication).thenReturn(new Authentication(MockProvider.EXAMPLE_USER_ID, groupIds, tenantIds)); FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(500L); given().contentType(ContentType.JSON).body(fetchExternalTasksDto).pathParam("name", "default").when().post(FETCH_EXTERNAL_TASK_URL_NAMED_ENGINE); ArgumentCaptor <Authentication> argumentCaptor = ArgumentCaptor.forClass(typeof(Authentication)); verify(identityServiceMock, atLeastOnce()).Authentication = argumentCaptor.capture(); assertThat(argumentCaptor.Value.UserId, @is(MockProvider.EXAMPLE_USER_ID)); assertThat(argumentCaptor.Value.GroupIds, @is(groupIds)); assertThat(argumentCaptor.Value.TenantIds, @is(tenantIds)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSetWriteBufferWatermarkOnChannelConfigWhenInstalled() public virtual void ShouldSetWriteBufferWatermarkOnChannelConfigWhenInstalled() { // given TransportThrottle throttle = NewThrottle(); // when throttle.Install(_channel); // expect ArgumentCaptor <WriteBufferWaterMark> argument = ArgumentCaptor.forClass(typeof(WriteBufferWaterMark)); verify(_config, times(1)).WriteBufferWaterMark = argument.capture(); assertEquals(64, argument.Value.low()); assertEquals(256, argument.Value.high()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void lockResultMustHaveMessageWhenAcquiringSharedLockWithoutConversation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void LockResultMustHaveMessageWhenAcquiringSharedLockWithoutConversation() { MasterImpl.SPI spi = MockedSpi(); ConversationManager conversationManager = mock(typeof(ConversationManager)); Config config = config(); MasterImpl master = new MasterImpl(spi, conversationManager, null, config); RequestContext context = CreateRequestContext(master); when(conversationManager.Acquire(context)).thenThrow(new NoSuchEntryException("")); master.AcquireSharedLock(context, ResourceTypes.NODE, 1); ArgumentCaptor <LockResult> captor = ArgumentCaptor.forClass(typeof(LockResult)); verify(spi).packTransactionObligationResponse(MockitoHamcrest.argThat(@is(context)), captor.capture()); assertThat(captor.Value.Message, @is(not(nullValue()))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void appliesDefaultTuningConfigurationForConsistencyChecker() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AppliesDefaultTuningConfigurationForConsistencyChecker() { // given DatabaseLayout databaseLayout = _testDirectory.databaseLayout(); string[] args = new string[] { databaseLayout.DatabaseDirectory().AbsolutePath }; ConsistencyCheckService service = mock(typeof(ConsistencyCheckService)); // when RunConsistencyCheckToolWith(service, args); // then ArgumentCaptor <Config> config = ArgumentCaptor.forClass(typeof(Config)); verify(service).runFullConsistencyCheck(eq(databaseLayout), config.capture(), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), anyBoolean(), any(typeof(ConsistencyFlags))); assertFalse(config.Value.get(ConsistencyCheckSettings.ConsistencyCheckPropertyOwners)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @SuppressWarnings("rawtypes") public void masterResponseShouldBeUnpackedIfRequestTypeRequires() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MasterResponseShouldBeUnpackedIfRequestTypeRequires() { // Given ResponseUnpacker responseUnpacker = mock(typeof(ResponseUnpacker)); MadeUpClient client = _builder.clientWith(responseUnpacker); AddToLifeAndStart(_builder.server(), client); // When client.Multiply(42, 42); // Then ArgumentCaptor <Response> captor = ArgumentCaptor.forClass(typeof(Response)); verify(responseUnpacker).unpackResponse(captor.capture(), eq(NO_OP_TX_HANDLER)); assertEquals(_storeIdToUse, captor.Value.StoreId); assertEquals(42 * 42, captor.Value.response()); }
public Void execute(CommandContext commandContext) { AuthorizationManager authorizationManager = outerInstance.spyOnSession(commandContext, typeof(AuthorizationManager)); DbEntityManager dbEntityManager = outerInstance.spyOnSession(commandContext, typeof(DbEntityManager)); outerInstance.authorizationService.isUserAuthorized(testUserId, null, Permissions.READ, Resources.TASK); verify(authorizationManager, atLeastOnce()).filterAuthenticatedGroupIds(eq((IList <string>)null)); ArgumentCaptor <AuthorizationCheck> authorizationCheckArgument = ArgumentCaptor.forClass(typeof(AuthorizationCheck)); verify(dbEntityManager).selectBoolean(eq("isUserAuthorizedForResource"), authorizationCheckArgument.capture()); AuthorizationCheck authorizationCheck = authorizationCheckArgument.Value; assertTrue(authorizationCheck.AuthGroupIds.Count == 0); return(null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void clientShouldUseHandlersToHandleComExceptions() public virtual void ClientShouldUseHandlersToHandleComExceptions() { // Given const string comExceptionMessage = "The ComException"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: MadeUpCommunicationInterface communication = mock(MadeUpCommunicationInterface.class, (org.mockito.stubbing.Answer<Response<?>>) ignored -> MadeUpCommunicationInterface communication = mock(typeof(MadeUpCommunicationInterface), (Answer <Response <object> >)ignored => { throw new ComException(comExceptionMessage); }); ComExceptionHandler handler = mock(typeof(ComExceptionHandler)); _life.add(_builder.server(communication)); MadeUpClient client = _life.add(_builder.client()); client.ComExceptionHandler = handler; _life.start(); // When ComException exceptionThrownOnRequest = null; try { client.Multiply(1, 10); } catch (ComException e) { exceptionThrownOnRequest = e; } // Then assertNotNull(exceptionThrownOnRequest); assertEquals(comExceptionMessage, exceptionThrownOnRequest.Message); ArgumentCaptor <ComException> exceptionCaptor = ArgumentCaptor.forClass(typeof(ComException)); verify(handler).handle(exceptionCaptor.capture()); assertEquals(comExceptionMessage, exceptionCaptor.Value.Message); verifyNoMoreInteractions(handler); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertTransactionsCommitted(long startTxId, long expectedCount) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException private void AssertTransactionsCommitted(long startTxId, long expectedCount) { ArgumentCaptor <TransactionToApply> batchCaptor = ArgumentCaptor.forClass(typeof(TransactionToApply)); verify(_commitProcess).commit(batchCaptor.capture(), eq(NULL), eq(EXTERNAL)); TransactionToApply batch = Iterables.single(batchCaptor.AllValues); long expectedTxId = startTxId; long count = 0; while (batch != null) { assertEquals(expectedTxId, batch.TransactionId()); expectedTxId++; batch = batch.Next(); count++; } assertEquals(expectedCount, count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRejectRequestDueToShutdown() public virtual void shouldRejectRequestDueToShutdown() { // given AsyncResponse asyncResponse = mock(typeof(AsyncResponse)); handler.addPendingRequest(createDto(5000L), asyncResponse, processEngine); handler.acquire(); // assume assertThat(handler.PendingRequests.Count, @is(1)); // when handler.rejectPendingRequests(); // then ArgumentCaptor <RestException> argumentCaptor = ArgumentCaptor.forClass(typeof(RestException)); verify(asyncResponse).resume(argumentCaptor.capture()); assertThat(argumentCaptor.Value.Status, @is(Status.INTERNAL_SERVER_ERROR)); assertThat(argumentCaptor.Value.Message, @is("Request rejected due to shutdown of application server.")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldResumeAsyncResponseDueToTimeoutExceeded() public virtual void shouldResumeAsyncResponseDueToTimeoutExceeded() { // given - no pending requests // assume assertThat(handler.PendingRequests.Count, @is(0)); // when AsyncResponse asyncResponse = mock(typeof(AsyncResponse)); handler.addPendingRequest(createDto(FetchAndLockHandlerImpl.MAX_REQUEST_TIMEOUT + 1), asyncResponse, processEngine); // then verify(handler, never()).suspend(anyLong()); assertThat(handler.PendingRequests.Count, @is(0)); ArgumentCaptor <InvalidRequestException> argumentCaptor = ArgumentCaptor.forClass(typeof(InvalidRequestException)); verify(asyncResponse).resume(argumentCaptor.capture()); assertThat(argumentCaptor.Value.Message, @is("The asynchronous response timeout cannot " + "be set to a value greater than " + FetchAndLockHandlerImpl.MAX_REQUEST_TIMEOUT + " milliseconds")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void passesOnConfigurationIfProvided() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void PassesOnConfigurationIfProvided() { // given DatabaseLayout databaseLayout = _testDirectory.databaseLayout(); File configFile = _testDirectory.file(Config.DEFAULT_CONFIG_FILE_NAME); Properties properties = new Properties(); properties.setProperty(ConsistencyCheckSettings.ConsistencyCheckPropertyOwners.name(), "true"); properties.store(new StreamWriter(configFile), null); string[] args = new string[] { databaseLayout.DatabaseDirectory().AbsolutePath, "-config", configFile.Path }; ConsistencyCheckService service = mock(typeof(ConsistencyCheckService)); // when RunConsistencyCheckToolWith(service, args); // then ArgumentCaptor <Config> config = ArgumentCaptor.forClass(typeof(Config)); verify(service).runFullConsistencyCheck(eq(databaseLayout), config.capture(), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), anyBoolean(), any(typeof(ConsistencyFlags))); assertTrue(config.Value.get(ConsistencyCheckSettings.ConsistencyCheckPropertyOwners)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void passesOnConfigurationIfProvided() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void PassesOnConfigurationIfProvided() { // given File configFile = _testDirectory.file(Config.DEFAULT_CONFIG_FILE_NAME); Properties properties = new Properties(); properties.setProperty(ConsistencyCheckSettings.consistency_check_property_owners.name(), "true"); properties.store(new StreamWriter(configFile), null); string[] args = new string[] { "-host", "localhost", "-to", "my_backup", "-config", configFile.Path }; BackupProtocolService service = mock(typeof(BackupProtocolService)); PrintStream systemOut = mock(typeof(PrintStream)); // when (new BackupTool(service, systemOut)).Run(args); // then ArgumentCaptor <Config> config = ArgumentCaptor.forClass(typeof(Config)); verify(service).doIncrementalBackupOrFallbackToFull(anyString(), anyInt(), eq(DatabaseLayout.of(Paths.get("my_backup").toFile())), any(typeof(ConsistencyCheck)), config.capture(), anyLong(), eq(false)); assertTrue(config.Value.get(ConsistencyCheckSettings.consistency_check_property_owners)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void lockResultMustHaveMessageWhenAcquiringSharedLockThrowsIllegalResource() public virtual void LockResultMustHaveMessageWhenAcquiringSharedLockThrowsIllegalResource() { MasterImpl.SPI spi = MockedSpi(); DefaultConversationSPI conversationSpi = MockedConversationSpi(); Config config = config(); ConversationManager conversationManager = new ConversationManager(conversationSpi, config); conversationManager.Start(); Locks_Client locks = mock(typeof(Locks_Client)); MasterImpl master = new MasterImpl(spi, conversationManager, null, config); RequestContext context = CreateRequestContext(master); when(conversationSpi.AcquireClient()).thenReturn(locks); ResourceTypes type = ResourceTypes.NODE; doThrow(new IllegalResourceException("")).when(locks).acquireExclusive(LockTracer.NONE, type, 1); master.AcquireSharedLock(context, type, 1); ArgumentCaptor <LockResult> captor = ArgumentCaptor.forClass(typeof(LockResult)); verify(spi).packTransactionObligationResponse(MockitoHamcrest.argThat(@is(context)), captor.capture()); assertThat(captor.Value.Message, @is(not(nullValue()))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldOnlySummarizeStatisticsWhenAllReferencesAreChecked() public virtual void ShouldOnlySummarizeStatisticsWhenAllReferencesAreChecked() { // given ConsistencySummaryStatistics summary = mock(typeof(ConsistencySummaryStatistics)); RecordAccess records = mock(typeof(RecordAccess)); ConsistencyReporter.ReportHandler handler = new ConsistencyReporter.ReportHandler(new InconsistencyReport(mock(typeof(InconsistencyLogger)), summary), mock(typeof(ConsistencyReporter.ProxyFactory)), RecordType.PROPERTY, records, new PropertyRecord(0), NO_MONITOR); RecordReference <PropertyRecord> reference = mock(typeof(RecordReference)); ComparativeRecordChecker <PropertyRecord, PropertyRecord, ConsistencyReport_PropertyConsistencyReport> checker = mock(typeof(ComparativeRecordChecker)); handler.comparativeCheck(reference, checker); ArgumentCaptor <PendingReferenceCheck <PropertyRecord> > captor = ( ArgumentCaptor )ArgumentCaptor.forClass(typeof(PendingReferenceCheck)); verify(reference).dispatch(captor.capture()); PendingReferenceCheck pendingRefCheck = captor.Value; // when handler.updateSummary(); // then verifyZeroInteractions(summary); // when pendingRefCheck.skip(); // then verify(summary).update(RecordType.PROPERTY, 0, 0); verifyNoMoreInteractions(summary); }