Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void visitOnlyLabeledNodes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void VisitOnlyLabeledNodes()
        {
            LabelScanReader labelScanReader = mock(typeof(LabelScanReader));

            when(_labelScanStore.newReader()).thenReturn(labelScanReader);
            when(_nodeLabelRanges.maxCount()).thenReturn(1L);

            PrimitiveLongResourceIterator labeledNodesIterator = PrimitiveLongResourceCollections.iterator(null, 1, 2, 3, 4, 5, 6, 7, 8);

            when(_nodeStore.HighestPossibleIdInUse).thenReturn(200L);
            when(_nodeStore.HighId).thenReturn(20L);
            when(labelScanReader.NodesWithAnyOfLabels(new int[] { 2, 6 })).thenReturn(labeledNodesIterator);
            when(_nodeStore.openPageCursorForReading(anyLong())).thenReturn(mock(typeof(PageCursor)));

            MockLabelNodeCount(_countStore, 2);
            MockLabelNodeCount(_countStore, 6);

            DynamicIndexStoreView storeView = DynamicIndexStoreView();

            StoreScan <Exception> storeScan = storeView.VisitNodes(new int[] { 2, 6 }, _propertyKeyIdFilter, _propertyUpdateVisitor, _labelUpdateVisitor, false);

            storeScan.Run();

            Mockito.verify(_nodeStore, times(8)).getRecordByCursor(anyLong(), any(typeof(NodeRecord)), any(typeof(RecordLoad)), any(typeof(PageCursor)));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void closeResource()
        public virtual void CloseResource()
        {
            Resource resource = Mockito.mock(typeof(Resource));
            PrimitiveLongResourceIterator source = resourceIterator(ImmutableEmptyLongIterator.INSTANCE, resource);

            PrimitiveLongResourceIterator iterator = DiffApplyingPrimitiveLongIterator.Augment(source, LongSets.immutable.empty(), LongSets.immutable.empty());

            iterator.Close();

            Mockito.verify(resource).close();
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStopJob() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStopJob()
        {
            // given
            BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance);

            // when
            batchHandler.Stop();

            // then
            Mockito.verify(_mockJob).stop();
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStartJob() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStartJob()
        {
            // given
            BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance);
            ClusterId clusterId = new ClusterId(System.Guid.randomUUID());

            // when
            batchHandler.Start(clusterId);

            // then
            Mockito.verify(_mockJob).start();
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSimpleTaskQuery()
        public virtual void testSimpleTaskQuery()
        {
            Response response = given().header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.OK.StatusCode).when().get(EXTERNAL_TASK_QUERY_URL);

            Mockito.verify(mockQuery).list();

            string         content   = response.asString();
            IList <string> instances = from(content).getList("");

            Assert.assertEquals("There should be one external task returned.", 1, instances.Count);
            Assert.assertNotNull("The returned external task should not be null.", instances[0]);

            string activityId         = from(content).getString("[0].activityId");
            string activityInstanceId = from(content).getString("[0].activityInstanceId");
            string errorMessage       = from(content).getString("[0].errorMessage");
            string executionId        = from(content).getString("[0].executionId");
            string id = from(content).getString("[0].id");
            string lockExpirationTime   = from(content).getString("[0].lockExpirationTime");
            string processDefinitionId  = from(content).getString("[0].processDefinitionId");
            string processDefinitionKey = from(content).getString("[0].processDefinitionKey");
            string processInstanceId    = from(content).getString("[0].processInstanceId");
            int?   retries     = from(content).getInt("[0].retries");
            bool?  suspended   = from(content).getBoolean("[0].suspended");
            string topicName   = from(content).getString("[0].topicName");
            string workerId    = from(content).getString("[0].workerId");
            string tenantId    = from(content).getString("[0].tenantId");
            long   priority    = from(content).getLong("[0].priority");
            string businessKey = from(content).getString("[0].businessKey");

            Assert.assertEquals(MockProvider.EXAMPLE_ACTIVITY_ID, activityId);
            Assert.assertEquals(MockProvider.EXAMPLE_ACTIVITY_INSTANCE_ID, activityInstanceId);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_ERROR_MESSAGE, errorMessage);
            Assert.assertEquals(MockProvider.EXAMPLE_EXECUTION_ID, executionId);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_ID, id);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_LOCK_EXPIRATION_TIME, lockExpirationTime);
            Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, processDefinitionId);
            Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY, processDefinitionKey);
            Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, processInstanceId);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_RETRIES, retries);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_SUSPENDED, suspended);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_TOPIC_NAME, topicName);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_WORKER_ID, workerId);
            Assert.assertEquals(MockProvider.EXAMPLE_TENANT_ID, tenantId);
            Assert.assertEquals(MockProvider.EXTERNAL_TASK_PRIORITY, priority);
            Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY, businessKey);
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotProvideStreamingForOtherMediaTypes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CannotProvideStreamingForOtherMediaTypes()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.ws.rs.core.Response.ResponseBuilder responseBuilder = mock(javax.ws.rs.core.Response.ResponseBuilder.class);
            Response.ResponseBuilder responseBuilder = mock(typeof(Response.ResponseBuilder));
            // no streaming
            when(responseBuilder.entity(any(typeof(sbyte[])))).thenReturn(responseBuilder);
            Mockito.verify(responseBuilder, never()).entity(isA(typeof(StreamingOutput)));
            when(responseBuilder.type(ArgumentMatchers.any <MediaType>())).thenReturn(responseBuilder);
            when(responseBuilder.build()).thenReturn(null);
            OutputFormat format = _repository.outputFormat(new IList <MediaType> {
                MediaType.TEXT_HTML_TYPE
            }, new URI("http://some.host"), StreamingHeader());

            assertNotNull(format);
            format.Response(responseBuilder, new ExceptionRepresentation(new Exception()));
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToForceStoreScan() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToForceStoreScan()
        {
            when(_labelScanStore.newReader()).thenThrow(new Exception("Should not be used"));

            when(_nodeStore.HighestPossibleIdInUse).thenReturn(200L);
            when(_nodeStore.HighId).thenReturn(20L);
            when(_nodeStore.openPageCursorForReading(anyLong())).thenReturn(mock(typeof(PageCursor)));

            MockLabelNodeCount(_countStore, 2);
            MockLabelNodeCount(_countStore, 6);

            DynamicIndexStoreView storeView = DynamicIndexStoreView();

            StoreScan <Exception> storeScan = storeView.VisitNodes(new int[] { 2, 6 }, _propertyKeyIdFilter, _propertyUpdateVisitor, _labelUpdateVisitor, true);

            storeScan.Run();

            Mockito.verify(_nodeStore, times(1)).getRecordByCursor(anyLong(), any(typeof(NodeRecord)), any(typeof(RecordLoad)), any(typeof(PageCursor)));
            Mockito.verify(_nodeStore, times(200)).nextRecordByCursor(any(typeof(NodeRecord)), any(typeof(RecordLoad)), any(typeof(PageCursor)));
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBackoffAndFailIfTooManyAttempts() throws java.io.IOException, InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBackoffAndFailIfTooManyAttempts()
        {
            // given
            HttpCopier.Sleeper sleeper = mock(typeof(HttpCopier.Sleeper));
            HttpCopier         copier  = new HttpCopier(new ControlledOutsideWorld(_fs), sleeper, _noOpProgress);
            Path   source       = CreateDump();
            long   sourceLength = _fs.getFileSize(source.toFile());
            string authorizationTokenResponse = "abc";
            string signedURIPath      = "/signed";
            string uploadLocationPath = "/upload";

            WireMock.stubFor(AuthenticationRequest(false).willReturn(SuccessfulAuthorizationResponse(authorizationTokenResponse)));
            WireMock.stubFor(InitiateUploadTargetRequest(authorizationTokenResponse).willReturn(SuccessfulInitiateUploadTargetResponse(signedURIPath)));
            WireMock.stubFor(InitiateUploadRequest(signedURIPath).willReturn(SuccessfulInitiateUploadResponse(uploadLocationPath)));
            WireMock.stubFor(ResumeUploadRequest(uploadLocationPath, sourceLength).willReturn(aResponse().withStatus(HTTP_INTERNAL_ERROR)));
            WireMock.stubFor(GetResumablePositionRequest(sourceLength, uploadLocationPath).willReturn(UploadIncompleteGetResumablePositionResponse(0)));

            // when/then
            AssertThrows(typeof(CommandFailed), containsString("Upload failed after numerous attempts"), () => authenticateAndCopy(copier, source, "user", "pass".ToCharArray()));
            Mockito.verify(sleeper, atLeast(30)).sleep(anyLong());
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() throws org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException, java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpdateForHigherNodeIgnoredWhenUsingFullNodeStoreScan()
        {
            NeoStores neoStores = Mockito.mock(typeof(NeoStores));
            NodeStore nodeStore = mock(typeof(NodeStore));

            when(neoStores.NodeStore).thenReturn(nodeStore);

            ProcessListenableNeoStoreIndexView storeView      = new ProcessListenableNeoStoreIndexView(this, LockService.NO_LOCK_SERVICE, neoStores);
            MultipleIndexPopulator             indexPopulator = new MultipleIndexPopulator(storeView, _logProvider, EntityType.NODE, mock(typeof(SchemaState)));

            storeView.ProcessListener = new NodeUpdateProcessListener(indexPopulator);

            IndexPopulator populator    = CreateIndexPopulator();
            IndexUpdater   indexUpdater = mock(typeof(IndexUpdater));

            AddPopulator(indexPopulator, populator, 1, TestIndexDescriptorFactory.forLabel(1, 1));

            indexPopulator.Create();
            StoreScan <IndexPopulationFailedKernelException> storeScan = indexPopulator.IndexAllEntities();

            storeScan.Run();

            Mockito.verify(indexUpdater, never()).process(any(typeof(IndexEntryUpdate)));
        }