コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAggregateProgressFromMultipleProcesses()
        public virtual void ShouldAggregateProgressFromMultipleProcesses()
        {
            // given
            Indicator indicator = IndicatorMock();

            ProgressMonitorFactory.MultiPartBuilder builder = Factory.mock(indicator, 10).multipleParts(TestName.MethodName);
            ProgressListener first = builder.ProgressForPart("first", 5);
            ProgressListener other = builder.ProgressForPart("other", 5);

            builder.Build();
            InOrder order = inOrder(indicator);

            order.verify(indicator).startProcess(10);
            order.verifyNoMoreInteractions();

            // when
            first.Started();
            for (int i = 0; i < 5; i++)
            {
                first.Add(1);
            }
            first.Done();

            // then
            order.verify(indicator).startPart("first", 5);
            for (int i = 0; i < 5; i++)
            {
                order.verify(indicator).progress(i, i + 1);
            }
            order.verify(indicator).completePart("first");
            order.verifyNoMoreInteractions();

            // when
            other.Started();
            for (int i = 0; i < 5; i++)
            {
                other.Add(1);
            }
            other.Done();

            // then
            order.verify(indicator).startPart("other", 5);
            for (int i = 5; i < 10; i++)
            {
                order.verify(indicator).progress(i, i + 1);
            }
            order.verify(indicator).completePart("other");
            order.verify(indicator).completeProcess();
            order.verifyNoMoreInteractions();
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseLockGroupAfterAppliers() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCloseLockGroupAfterAppliers()
        {
            // given
            long        nodeId      = 5;
            LockService lockService = mock(typeof(LockService));
            Lock        nodeLock    = mock(typeof(Lock));

            when(lockService.AcquireNodeLock(nodeId, Org.Neo4j.Kernel.impl.locking.LockService_LockType.WriteLock)).thenReturn(nodeLock);
            System.Action <bool> applierCloseCall          = mock(typeof(System.Action));         // <-- simply so that we can use InOrder mockito construct
            CapturingBatchTransactionApplierFacade applier = new CapturingBatchTransactionApplierFacade(this, applierCloseCall);
            RecordStorageEngine engine          = RecordStorageEngineBuilder().lockService(lockService).transactionApplierTransformer(applier.wrapAroundActualApplier).build();
            CommandsToApply     commandsToApply = mock(typeof(CommandsToApply));

            when(commandsToApply.Accept(any())).thenAnswer(invocationOnMock =>
            {
                // Visit one node command
                Visitor <StorageCommand, IOException> visitor = invocationOnMock.getArgument(0);
                NodeRecord after = new NodeRecord(nodeId);
                after.InUse      = true;
                visitor.visit(new Command.NodeCommand(new NodeRecord(nodeId), after));
                return(null);
            });

            // when
            engine.Apply(commandsToApply, TransactionApplicationMode.INTERNAL);

            // then
            InOrder inOrder = inOrder(lockService, applierCloseCall, nodeLock);

            inOrder.verify(lockService).acquireNodeLock(nodeId, Org.Neo4j.Kernel.impl.locking.LockService_LockType.WriteLock);
            inOrder.verify(applierCloseCall).accept(true);
            inOrder.verify(nodeLock, times(1)).release();
            inOrder.verifyNoMoreInteractions();
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportProgressInTheSpecifiedIntervals()
        public virtual void ShouldReportProgressInTheSpecifiedIntervals()
        {
            // given
            Indicator        indicator        = IndicatorMock();
            ProgressListener progressListener = Factory.mock(indicator, 10).singlePart(TestName.MethodName, 16);

            // when
            progressListener.Started();
            for (int i = 0; i < 16; i++)
            {
                progressListener.Add(1);
            }
            progressListener.Done();

            // then
            InOrder order = inOrder(indicator);

            order.verify(indicator).startProcess(16);
            for (int i = 0; i < 10; i++)
            {
                order.verify(indicator).progress(i, i + 1);
            }
            order.verify(indicator).completeProcess();
            order.verifyNoMoreInteractions();
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCloseGlobalAllocationsOnClose()
        internal virtual void ShouldCloseGlobalAllocationsOnClose()
        {
            // given
            ByteBufferFactory.Allocator allocator = mock(typeof(ByteBufferFactory.Allocator));
            when(allocator.Allocate(anyInt())).thenAnswer(invocationOnMock => ByteBuffer.allocate(invocationOnMock.getArgument(0)));
            ByteBufferFactory factory = new ByteBufferFactory(() => allocator, 100);

            // when doing some allocations that are counted as global
            factory.AcquireThreadLocalBuffer();
            factory.ReleaseThreadLocalBuffer();
            factory.AcquireThreadLocalBuffer();
            factory.ReleaseThreadLocalBuffer();
            factory.GlobalAllocator().allocate(123);
            factory.GlobalAllocator().allocate(456);
            // and closing it
            factory.Close();

            // then
            InOrder inOrder = inOrder(allocator);

            inOrder.verify(allocator, times(1)).allocate(100);
            inOrder.verify(allocator, times(1)).allocate(123);
            inOrder.verify(allocator, times(1)).allocate(456);
            inOrder.verify(allocator, times(1)).close();
            inOrder.verifyNoMoreInteractions();
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testValidSortingParameters()
        public virtual void testValidSortingParameters()
        {
            given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).queryParam("sortOrder", "asc").queryParam("sortBy", "activityId").then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_ACTIVITY_STATISTICS_URL);

            InOrder inOrder = Mockito.inOrder(historicActivityStatisticsQuery);

            inOrder.verify(historicActivityStatisticsQuery).orderByActivityId();
            inOrder.verify(historicActivityStatisticsQuery).asc();
            inOrder.verify(historicActivityStatisticsQuery).list();
            inOrder.verifyNoMoreInteractions();

            given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).queryParam("sortOrder", "desc").queryParam("sortBy", "activityId").then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_ACTIVITY_STATISTICS_URL);

            inOrder = Mockito.inOrder(historicActivityStatisticsQuery);
            inOrder.verify(historicActivityStatisticsQuery).orderByActivityId();
            inOrder.verify(historicActivityStatisticsQuery).desc();
            inOrder.verify(historicActivityStatisticsQuery).list();
            inOrder.verifyNoMoreInteractions();
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAdditionalCompleteScopeOption()
        public virtual void testAdditionalCompleteScopeOption()
        {
            given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).queryParam("completeScope", "true").then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_ACTIVITY_STATISTICS_URL);

            InOrder inOrder = Mockito.inOrder(historicActivityStatisticsQuery);

            inOrder.verify(historicActivityStatisticsQuery).includeCompleteScope();
            inOrder.verify(historicActivityStatisticsQuery).list();
            inOrder.verifyNoMoreInteractions();
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryActiveBatches()
        public virtual void testQueryActiveBatches()
        {
            Response response = given().queryParam("suspended", false).then().expect().statusCode(Status.OK.StatusCode).when().get(BATCH_STATISTICS_URL);

            InOrder inOrder = inOrder(queryMock);

            inOrder.verify(queryMock).active();
            inOrder.verify(queryMock).list();
            inOrder.verifyNoMoreInteractions();

            verifyBatchStatisticsListJson(response.asString());
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBatchQueryByBatchId()
        public virtual void testBatchQueryByBatchId()
        {
            Response response = given().queryParam("batchId", MockProvider.EXAMPLE_BATCH_ID).then().expect().statusCode(Status.OK.StatusCode).when().get(BATCH_STATISTICS_URL);

            InOrder inOrder = inOrder(queryMock);

            inOrder.verify(queryMock).batchId(MockProvider.EXAMPLE_BATCH_ID);
            inOrder.verify(queryMock).list();
            inOrder.verifyNoMoreInteractions();

            verifyBatchStatisticsListJson(response.asString());
        }
コード例 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHistoricBatchQueryByNotCompleted()
        public virtual void testHistoricBatchQueryByNotCompleted()
        {
            Response response = given().queryParam("completed", false).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_BATCH_RESOURCE_URL);

            InOrder inOrder = inOrder(queryMock);

            inOrder.verify(queryMock).completed(false);
            inOrder.verify(queryMock).list();
            inOrder.verifyNoMoreInteractions();

            verifyHistoricBatchListJson(response.asString());
        }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetHistoricBatch()
        public virtual void testGetHistoricBatch()
        {
            Response response = given().pathParam("id", MockProvider.EXAMPLE_BATCH_ID).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_SINGLE_BATCH_RESOURCE_URL);

            InOrder inOrder = inOrder(queryMock);

            inOrder.verify(queryMock).batchId(MockProvider.EXAMPLE_BATCH_ID);
            inOrder.verify(queryMock).singleResult();
            inOrder.verifyNoMoreInteractions();

            verifyHistoricBatchJson(response.asString());
        }
コード例 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAdditionalFinishedBeforeOption()
        public virtual void testAdditionalFinishedBeforeOption()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.Date testDate = new java.util.Date(0);
            DateTime testDate = new DateTime();

            given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).queryParam("finishedBefore", DATE_FORMAT_WITH_TIMEZONE.format(testDate)).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_ACTIVITY_STATISTICS_URL);

            InOrder inOrder = Mockito.inOrder(historicActivityStatisticsQuery);

            inOrder.verify(historicActivityStatisticsQuery).finishedBefore(testDate);
            inOrder.verify(historicActivityStatisticsQuery).list();
            inOrder.verifyNoMoreInteractions();
        }
コード例 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToEndWithSuccess()
        public virtual void ShouldBeAbleToEndWithSuccess()
        {
            // given
            StoreFileStreamingProtocol protocol = new StoreFileStreamingProtocol();
            ChannelHandlerContext      ctx      = mock(typeof(ChannelHandlerContext));

            // when
            protocol.End(ctx, StoreCopyFinishedResponse.Status.Success);

            // then
            InOrder inOrder = Mockito.inOrder(ctx);

            inOrder.verify(ctx).write(ResponseMessageType.STORE_COPY_FINISHED);
            inOrder.verify(ctx).writeAndFlush(new StoreCopyFinishedResponse(SUCCESS));
            inOrder.verifyNoMoreInteractions();
        }
コード例 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteMultiPartProgressWithNoPartsImmediately()
        public virtual void ShouldCompleteMultiPartProgressWithNoPartsImmediately()
        {
            // given
            Indicator indicator = IndicatorMock();

            ProgressMonitorFactory.MultiPartBuilder builder = Factory.mock(indicator, 10).multipleParts(TestName.MethodName);

            // when
            builder.Build();

            // then
            InOrder order = inOrder(indicator);

            order.verify(indicator).startProcess(0);
            order.verify(indicator).progress(0, 10);
            order.verify(indicator).completeProcess();
            order.verifyNoMoreInteractions();
        }
コード例 #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseReEntryMethodsOnLocalLocksForReEntryShared()
        public virtual void ShouldUseReEntryMethodsOnLocalLocksForReEntryShared()
        {
            // Given we have grabbed and released a lock
            _client.acquireShared(LockTracer.NONE, NODE, 1L);

            // When we grab and release that lock again
            _client.acquireShared(LockTracer.NONE, NODE, 1L);
            _client.releaseShared(NODE, 1L);

            // Then this should cause the local lock manager to hold the lock
            InOrder order = inOrder(_local);

            order.verify(_local, times(1)).reEnterShared(NODE, 1L);
            order.verify(_local, times(1)).trySharedLock(NODE, 1L);
            order.verify(_local, times(1)).reEnterShared(NODE, 1L);
            order.verify(_local, times(1)).releaseShared(NODE, 1L);
            order.verifyNoMoreInteractions();
        }
コード例 #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldPrintUsageForAllCommandsAlphabetically()
        internal virtual void ShouldPrintUsageForAllCommandsAlphabetically()
        {
            AdminCommandSection generalSection = AdminCommandSection.General();

            IList <AdminCommand_Provider> providers = new IList <AdminCommand_Provider> {
                MockCommand("restore", "Restore"), MockCommand("bam", "A summary"), MockCommand("zzzz-last-one", "Another summary")
            };

            generalSection.PrintAllCommandsUnderSection(@out, providers);

            InOrder ordered = inOrder(@out);

            ordered.verify(@out).accept("");
            ordered.verify(@out).accept("General");
            ordered.verify(@out).accept("    bam");
            ordered.verify(@out).accept("        A summary");
            ordered.verify(@out).accept("    restore");
            ordered.verify(@out).accept("        Restore");
            ordered.verify(@out).accept("    zzzz-last-one");
            ordered.verify(@out).accept("        Another summary");
            ordered.verifyNoMoreInteractions();
        }
コード例 #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStartProcessAutomaticallyIfNotDoneBefore()
        public virtual void ShouldStartProcessAutomaticallyIfNotDoneBefore()
        {
            // given
            Indicator        indicator        = IndicatorMock();
            ProgressListener progressListener = Factory.mock(indicator, 10).singlePart(TestName.MethodName, 16);

            // when
            for (int i = 0; i < 16; i++)
            {
                progressListener.Add(1);
            }
            progressListener.Done();

            // then
            InOrder order = inOrder(indicator);

            order.verify(indicator, times(1)).startProcess(16);
            for (int i = 0; i < 10; i++)
            {
                order.verify(indicator).progress(i, i + 1);
            }
            order.verify(indicator).completeProcess();
            order.verifyNoMoreInteractions();
        }