Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSecondarySortingAsPost()
        public virtual void testSecondarySortingAsPost()
        {
            InOrder inOrder = Mockito.inOrder(mockedQuery);
            IDictionary <string, object> json = new Dictionary <string, object>();

            json["sorting"] = OrderingBuilder.create().orderBy("processInstanceId").desc().orderBy("timestamp").asc().Json;
            given().contentType(POST_JSON_CONTENT_TYPE).body(json).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.OK.StatusCode).when().post(HISTORIC_JOB_LOG_RESOURCE_URL);

            inOrder.verify(mockedQuery).orderByProcessInstanceId();
            inOrder.verify(mockedQuery).desc();
            inOrder.verify(mockedQuery).orderByTimestamp();
            inOrder.verify(mockedQuery).asc();
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testPathNodes()
        internal virtual void TestPathNodes()
        {
            when(_spi.newNodeProxy(Mockito.anyLong())).thenAnswer(new NodeProxyAnswer(this));

            Path path = (new PathImpl.Builder(CreateNodeProxy(1))).push(CreateRelationshipProxy(1, 2)).push(CreateRelationshipProxy(2, 3)).build(new PathImpl.Builder(CreateNodeProxy(3)));

            IEnumerable <Node> nodes    = path.Nodes();
            IList <Node>       nodeList = Iterables.asList(nodes);

            assertEquals(3, nodeList.Count);
            assertEquals(1, nodeList[0].Id);
            assertEquals(2, nodeList[1].Id);
            assertEquals(3, nodeList[2].Id);
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCaseExecutionRetrievalAsPost()
        public virtual void testCaseExecutionRetrievalAsPost()
        {
            string queryCaseExecutionId = "aCaseExecutionId";

            IDictionary <string, string> queryParameter = new Dictionary <string, string>();

            queryParameter["caseExecutionId"] = queryCaseExecutionId;

            Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(queryParameter).then().expect().statusCode(Status.OK.StatusCode).when().post(CASE_EXECUTION_QUERY_URL);

            // assert query invocation
            InOrder inOrder = Mockito.inOrder(mockedQuery);

            inOrder.verify(mockedQuery).caseExecutionId(queryCaseExecutionId);
            inOrder.verify(mockedQuery).list();

            string content = response.asString();
            IList <IDictionary <string, string> > caseExecutions = from(content).getList("");

            assertThat(caseExecutions).hasSize(1);
            assertThat(caseExecutions[0]).NotNull;

            string returnedId                  = from(content).getString("[0].id");
            string returnedCaseInstanceId      = from(content).getString("[0].caseInstanceId");
            string returnedParentId            = from(content).getString("[0].parentId");
            string returnedCaseDefinitionId    = from(content).getString("[0].caseDefinitionId");
            string returnedActivityId          = from(content).getString("[0].activityId");
            string returnedActivityName        = from(content).getString("[0].activityName");
            string returnedActivityType        = from(content).getString("[0].activityType");
            string returnedActivityDescription = from(content).getString("[0].activityDescription");
            string returnedTenantId            = from(content).getString("[0].tenantId");
            bool   returnedRequired            = from(content).getBoolean("[0].required");
            bool   returnedActiveState         = from(content).getBoolean("[0].active");
            bool   returnedEnabledState        = from(content).getBoolean("[0].enabled");
            bool   returnedDisabledState       = from(content).getBoolean("[0].disabled");

            assertThat(returnedId).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_ID);
            assertThat(returnedCaseInstanceId).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_CASE_INSTANCE_ID);
            assertThat(returnedParentId).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_PARENT_ID);
            assertThat(returnedCaseDefinitionId).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_CASE_DEFINITION_ID);
            assertThat(returnedActivityId).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_ACTIVITY_ID);
            assertThat(returnedActivityName).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_ACTIVITY_NAME);
            assertThat(returnedActivityType).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_ACTIVITY_TYPE);
            assertThat(returnedActivityDescription).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_ACTIVITY_DESCRIPTION);
            assertThat(returnedTenantId).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
            assertThat(returnedRequired).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_IS_REQUIRED);
            assertThat(returnedEnabledState).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_IS_ENABLED);
            assertThat(returnedActiveState).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_IS_ACTIVE);
            assertThat(returnedDisabledState).isEqualTo(MockProvider.EXAMPLE_CASE_EXECUTION_IS_DISABLED);
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPluginInitialization()
        public virtual void TestPluginInitialization()
        {
            Config    config    = Config.defaults(ServerSettings.transaction_idle_timeout, "600");
            NeoServer neoServer = Mockito.mock(typeof(NeoServer), Mockito.RETURNS_DEEP_STUBS);

            Mockito.when(neoServer.Config).thenReturn(config);
            ExtensionInitializer extensionInitializer = new ExtensionInitializer(neoServer);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Collection<org.neo4j.server.plugins.Injectable<?>> injectableProperties = extensionInitializer.initializePackages(java.util.Collections.singletonList("org.neo4j.server.modules"));
            ICollection <Injectable <object> > injectableProperties = extensionInitializer.InitializePackages(Collections.singletonList("org.neo4j.server.modules"));

            assertTrue(injectableProperties.Any(i => ServerSettings.transaction_idle_timeout.name().Equals(i.Value)));
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldComputeIndexUpdatesForScanOnAnEmptyTxState()
        internal virtual void ShouldComputeIndexUpdatesForScanOnAnEmptyTxState()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState state = org.mockito.Mockito.mock(org.neo4j.storageengine.api.txstate.ReadableTransactionState.class);
            ReadableTransactionState state = Mockito.mock(typeof(ReadableTransactionState));

            // WHEN
            AddedAndRemoved           changes           = indexUpdatesForScan(state, _index, IndexOrder.NONE);
            AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForScan(state, _index, IndexOrder.NONE);

            // THEN
            assertTrue(changes.Empty);
            assertTrue(changesWithValues.Empty);
        }
Exemple #6
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();
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void recoveryIsPerformedBeforeRename() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RecoveryIsPerformedBeforeRename()
        {
            // given
            FallbackToFullPasses();
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            InOrder recoveryBeforeRenameOrder = Mockito.inOrder(_backupRecoveryService, _backupCopyService);

            recoveryBeforeRenameOrder.verify(_backupRecoveryService).recoverWithDatabase(eq(_availableFreshBackupLocation), any(), any());
            recoveryBeforeRenameOrder.verify(_backupCopyService).moveBackupLocation(eq(_availableFreshBackupLocation), eq(_desiredBackupLayout.databaseDirectory().toPath()));
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void electionShouldRemainLocalIfStartedBySingleInstanceWhichIsTheRoleHolder() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ElectionShouldRemainLocalIfStartedBySingleInstanceWhichIsTheRoleHolder()
        {
            /*
             * Ensures that when an instance is alone in the cluster, elections for roles that it holds do not set
             * timeouts or try to reach other instances.
             */

            // Given
            ElectionContext context            = mock(typeof(ElectionContext));
            ClusterContext  clusterContextMock = mock(typeof(ClusterContext));

            when(clusterContextMock.GetLog(ArgumentMatchers.any())).thenReturn(NullLog.Instance);
            MessageHolder holder = mock(typeof(MessageHolder));

            // These mean the election can proceed normally, by us
            when(context.ElectionOk()).thenReturn(true);
            when(context.InCluster).thenReturn(true);
            when(context.Elector).thenReturn(true);

            // Like it says on the box, we are the only instance
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.cluster.InstanceId myInstanceId = new org.neo4j.cluster.InstanceId(1);
            InstanceId myInstanceId = new InstanceId(1);
            IDictionary <InstanceId, URI> members = new Dictionary <InstanceId, URI>();

            members[myInstanceId] = URI.create("ha://me");
            when(context.Members).thenReturn(members);

            // Any role would do, just make sure we have it
            const string role = "master";
            ElectionContext_VoteRequest voteRequest = new ElectionContext_VoteRequest(role, 13);

            when(context.PossibleRoles).thenReturn(Collections.singletonList(new ElectionRole(role)));
            when(context.GetElected(role)).thenReturn(myInstanceId);
            when(context.VoteRequestForRole(new ElectionRole(role))).thenReturn(voteRequest);

            // Required for logging
            when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance);

            // When
            election.handle(context, Message.@internal(performRoleElections), holder);

            // Then
            // Make sure that we asked ourselves to vote for that role and that no timer was set
            verify(holder, times(1)).offer(ArgumentMatchers.argThat(new MessageArgumentMatcher <ElectionMessage>()
                                                                    .onMessageType(ElectionMessage.Vote).withPayload(voteRequest)));
            verify(context, never()).setTimeout(ArgumentMatchers.any(), ArgumentMatchers.any());
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnRelationshipDuplicateRuleFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnRelationshipDuplicateRuleFound()
        {
            // GIVEN
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            SchemaStorage schemaStorageSpy = Mockito.spy(_storage);

            Mockito.when(schemaStorageSpy.LoadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(GetRelationshipPropertyExistenceConstraintRule(1L, TYPE1, PROP1), GetRelationshipPropertyExistenceConstraintRule(2L, TYPE1, PROP1)));

            //EXPECT
            ExpectedException.expect(typeof(DuplicateSchemaRuleException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple relationship property existence constraints found for -[:Type1(prop1)]-."));

            // WHEN
            schemaStorageSpy.ConstraintsGetSingle(ConstraintDescriptorFactory.existsForRelType(TypeId(TYPE1), PropId(PROP1)));
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverBeforeNegotiation()
        public void shouldSendFailureIfSwitchOverBeforeNegotiation()
        {
            // given
            int version = 1;

            _server.handle(InitialMagicMessage.Instance());

            // when
            _server.handle(new SwitchOverRequest(RAFT_1.category(), version, emptyList()));

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

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
Exemple #11
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();
        }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotRenewTheTimeoutIfInPanicState()
        public virtual void ShouldNotRenewTheTimeoutIfInPanicState()
        {
            // given
            _txPuller.start();
            CatchUpResponseCallback callback = mock(typeof(CatchUpResponseCallback));

            doThrow(new Exception("Panic all the things")).when(callback).onTxPullResponse(any(typeof(CompletableFuture)), any(typeof(TxPullResponse)));
            Timer timer = Mockito.spy(single(_timerService.getTimers(TX_PULLER_TIMER)));

            // when
            _timerService.invoke(TX_PULLER_TIMER);

            // then
            assertEquals(PANIC, _txPuller.state());
            verify(timer, never()).reset();
        }
Exemple #13
0
            internal virtual ReadableTransactionState Build()
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.ReadableTransactionState mock = org.mockito.Mockito.mock(org.neo4j.storageengine.api.txstate.ReadableTransactionState.class);
                ReadableTransactionState mock = Mockito.mock(typeof(ReadableTransactionState));

                doReturn(new UnmodifiableMap <>(Updates)).when(mock).getIndexUpdates(any(typeof(SchemaDescriptor)));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.TreeMap<org.neo4j.values.storable.ValueTuple, org.neo4j.kernel.impl.util.diffsets.MutableLongDiffSetsImpl> sortedMap = new java.util.TreeMap<>(org.neo4j.values.storable.ValueTuple.COMPARATOR);
                SortedDictionary <ValueTuple, MutableLongDiffSetsImpl> sortedMap = new SortedDictionary <ValueTuple, MutableLongDiffSetsImpl>(ValueTuple.COMPARATOR);

//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
                sortedMap.putAll(Updates);
                doReturn(sortedMap).when(mock).getSortedIndexUpdates(any(typeof(SchemaDescriptor)));
                return(mock);
            }
Exemple #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnNodeDuplicateRuleFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnNodeDuplicateRuleFound()
        {
            // GIVEN
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            SchemaStorage schemaStorageSpy = Mockito.spy(_storage);

            Mockito.when(schemaStorageSpy.LoadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(GetUniquePropertyConstraintRule(1L, LABEL1, PROP1), GetUniquePropertyConstraintRule(2L, LABEL1, PROP1)));

            //EXPECT
            ExpectedException.expect(typeof(DuplicateSchemaRuleException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple uniqueness constraints found for :Label1(prop1)."));

            // WHEN
            schemaStorageSpy.ConstraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(LabelId(LABEL1), PropId(PROP1)));
        }
Exemple #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendNegativeResponseAndCloseForUnknownApplicationProtocol()
        public void shouldSendNegativeResponseAndCloseForUnknownApplicationProtocol()
        {
            // given
            ISet <int> versions = asSet(1, 2, 3);

            _server.handle(InitialMagicMessage.Instance());

            // when
            _server.handle(new ApplicationProtocolRequest("UNKNOWN", versions));

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

            inOrder.verify(_channel).writeAndFlush(ApplicationProtocolResponse.NoProtocol);
            inOrder.verify(_channel).dispose();
        }
Exemple #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportFailedPullUpdates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReportFailedPullUpdates()
        {
            // GIVEN
            UpdatePuller updatePuller = mock(typeof(UpdatePuller));
            Exception    myException  = new Exception("My test exception");

            Mockito.doThrow(myException).when(updatePuller).pullUpdates();
            _dependencies.satisfyDependency(updatePuller);

            // WHEN
            string result = _haBean.update();

            // THEN
            verify(updatePuller).pullUpdates();
            assertTrue(result, result.Contains(myException.Message));
        }
Exemple #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverDiffersFromNegotiatedProtocol()
        public void shouldSendFailureIfSwitchOverDiffersFromNegotiatedProtocol()
        {
            // given
            int version = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version)));

            // when
            _server.handle(new SwitchOverRequest(RAFT_1.category(), version + 1, emptyList()));

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

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
Exemple #18
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()));
        }
Exemple #19
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);
        }
Exemple #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSortingParameters()
        public virtual void testSortingParameters()
        {
            // asc
            InOrder inOrder = Mockito.inOrder(mockedQuery);

            executeAndVerifySorting("caseExecutionId", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByCaseExecutionId();
            inOrder.verify(mockedQuery).asc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySorting("caseDefinitionKey", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByCaseDefinitionKey();
            inOrder.verify(mockedQuery).asc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySorting("caseDefinitionId", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByCaseDefinitionId();
            inOrder.verify(mockedQuery).asc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySorting("tenantId", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByTenantId();
            inOrder.verify(mockedQuery).asc();

            // desc
            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySorting("caseExecutionId", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByCaseExecutionId();
            inOrder.verify(mockedQuery).desc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySorting("caseDefinitionKey", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByCaseDefinitionKey();
            inOrder.verify(mockedQuery).desc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySorting("caseDefinitionId", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByCaseDefinitionId();
            inOrder.verify(mockedQuery).desc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySorting("tenantId", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByTenantId();
            inOrder.verify(mockedQuery).desc();
        }
Exemple #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureOnUnknownProtocolSwitchOver()
        public void shouldSendFailureOnUnknownProtocolSwitchOver()
        {
            // given
            int    version             = 1;
            string unknownProtocolName = "UNKNOWN";

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(unknownProtocolName, asSet(version)));

            // when
            _server.handle(new SwitchOverRequest(unknownProtocolName, version, emptyList()));

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

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
Exemple #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void doNotRemoveRelativeTransactionDirectoryAgain() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNotRemoveRelativeTransactionDirectoryAgain()
        {
            FileSystemAbstraction fileSystem = Mockito.spy(FileSystemRule.get());
            File fromPath             = Directory.directory("from");
            File databaseFile         = Directory.directory();
            File relativeLogDirectory = Directory.directory("relativeDirectory");

            Config config = Config.defaults(GraphDatabaseSettings.database_path, databaseFile.AbsolutePath);

            config.augment(GraphDatabaseSettings.logical_logs_location, relativeLogDirectory.AbsolutePath);

            CreateDbAt(fromPath, 10);

            (new RestoreDatabaseCommand(fileSystem, fromPath, config, "testDatabase", true)).Execute();

            verify(fileSystem).deleteRecursively(eq(databaseFile));
            verify(fileSystem, never()).deleteRecursively(eq(relativeLogDirectory));
        }
Exemple #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBranchStoreUnlessWeHaveCopiedDownAReplacement() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBranchStoreUnlessWeHaveCopiedDownAReplacement()
        {
            // Given
            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));

            doAnswer(invocation =>
            {
                MoveAfterCopy moveAfterCopy = invocation.getArgument(2);
                moveAfterCopy.move(Stream.empty(), new File(""), Function.identity());
                return(null);
            }).when(storeCopyClient).copyStore(any(typeof(StoreCopyClient.StoreCopyRequester)), any(typeof(CancellationRequest)), any(typeof(MoveAfterCopy)));

            PageCache pageCacheMock = mock(typeof(PageCache));
            PagedFile pagedFileMock = mock(typeof(PagedFile));

            when(pagedFileMock.LastPageId).thenReturn(1L);
            when(pageCacheMock.Map(any(typeof(File)), anyInt())).thenReturn(pagedFileMock);

            SwitchToSlaveCopyThenBranch switchToSlave = NewSwitchToSlaveSpy(pageCacheMock, storeCopyClient);

            URI masterUri = new URI("cluster://localhost?serverId=1");
            URI me        = new URI("cluster://localhost?serverId=2");
            CancellationRequest cancellationRequest = Org.Neo4j.Helpers.CancellationRequest_Fields.NeverCancelled;

            MasterClient masterClient = mock(typeof(MasterClient));

            when(masterClient.Handshake(anyLong(), any(typeof(StoreId)))).thenThrow(new BranchedDataException(""));

            TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore));

            when(transactionIdStore.LastCommittedTransaction).thenReturn(new TransactionId(42, 42, 42));
            when(transactionIdStore.LastCommittedTransactionId).thenReturn(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID);

            // When
            BranchedDataPolicy branchPolicy = mock(typeof(BranchedDataPolicy));

            switchToSlave.StopServicesAndHandleBranchedStore(branchPolicy, masterUri, me, cancellationRequest);

            // Then
            InOrder inOrder = Mockito.inOrder(storeCopyClient, branchPolicy);

            inOrder.verify(storeCopyClient).copyStore(any(typeof(StoreCopyClient.StoreCopyRequester)), any(typeof(CancellationRequest)), any(typeof(MoveAfterCopy)));
            inOrder.verify(branchPolicy).handle(TestDirectory.databaseDir(), pageCacheMock, NullLogService.Instance);
        }
Exemple #24
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();
        }
Exemple #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void timeoutMakesElectionBeForgotten() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TimeoutMakesElectionBeForgotten()
        {
            // Given
            string coordinatorRole = "coordinator";

            ElectionContext context = mock(typeof(ElectionContext));

            when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance);

            MessageHolder holder = mock(typeof(MessageHolder));

            Message <ElectionMessage> timeout = Message.timeout(ElectionMessage.ElectionTimeout, Message.@internal(performRoleElections), new ElectionState.ElectionTimeoutData(coordinatorRole, null));

            // When
            election.handle(context, timeout, holder);

            // Then
            verify(context, times(1)).forgetElection(coordinatorRole);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCallTransactionClosedOnFailedForceLogToDisk() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotCallTransactionClosedOnFailedForceLogToDisk()
        {
            // GIVEN
            long   txId           = 3;
            string failureMessage = "Forces a failure";
            FlushablePositionAwareChannel channel = spy(new InMemoryClosableChannel());
            IOException failure = new IOException(failureMessage);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.Flushable flushable = mock(java.io.Flushable.class);
            Flushable flushable = mock(typeof(Flushable));

            doAnswer(invocation =>
            {
                invocation.callRealMethod();
                return(flushable);
            }).when(channel).prepareForFlush();
            doThrow(failure).when(flushable).flush();
            when(_logFile.Writer).thenReturn(channel);
            TransactionMetadataCache metadataCache      = new TransactionMetadataCache();
            TransactionIdStore       transactionIdStore = mock(typeof(TransactionIdStore));

            when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId);
            Mockito.reset(_databaseHealth);
            TransactionAppender appender = Life.add(new BatchingTransactionAppender(_logFiles, NO_ROTATION, metadataCache, transactionIdStore, BYPASS, _databaseHealth));

            // WHEN
            TransactionRepresentation transaction = mock(typeof(TransactionRepresentation));

            when(transaction.AdditionalHeader()).thenReturn(new sbyte[0]);
            try
            {
                appender.Append(new TransactionToApply(transaction), _logAppendEvent);
                fail("Expected append to fail. Something is wrong with the test itself");
            }
            catch (IOException e)
            {
                // THEN
                assertSame(failure, e);
                verify(transactionIdStore, times(1)).nextCommittingTransactionId();
                verify(transactionIdStore, never()).transactionClosed(eq(txId), anyLong(), anyLong());
                verify(_databaseHealth).panic(failure);
            }
        }
Exemple #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSortingParameters()
        public virtual void testSortingParameters()
        {
            InOrder inOrder = Mockito.inOrder(mockQuery);

            executeAndVerifySorting("jobId", "desc", Status.OK);
            inOrder.verify(mockQuery).orderByJobId();
            inOrder.verify(mockQuery).desc();

            inOrder = Mockito.inOrder(mockQuery);
            executeAndVerifySorting("processInstanceId", "asc", Status.OK);
            inOrder.verify(mockQuery).orderByProcessInstanceId();
            inOrder.verify(mockQuery).asc();

            inOrder = Mockito.inOrder(mockQuery);
            executeAndVerifySorting("executionId", "desc", Status.OK);
            inOrder.verify(mockQuery).orderByExecutionId();
            inOrder.verify(mockQuery).desc();

            inOrder = Mockito.inOrder(mockQuery);
            executeAndVerifySorting("jobRetries", "asc", Status.OK);
            inOrder.verify(mockQuery).orderByJobRetries();
            inOrder.verify(mockQuery).asc();

            inOrder = Mockito.inOrder(mockQuery);
            executeAndVerifySorting("jobDueDate", "desc", Status.OK);
            inOrder.verify(mockQuery).orderByJobDuedate();
            inOrder.verify(mockQuery).desc();

            inOrder = Mockito.inOrder(mockQuery);
            executeAndVerifySorting("jobPriority", "asc", Status.OK);
            inOrder.verify(mockQuery).orderByJobPriority();
            inOrder.verify(mockQuery).asc();

            inOrder = Mockito.inOrder(mockQuery);
            executeAndVerifySorting("tenantId", "asc", Status.OK);
            inOrder.verify(mockQuery).orderByTenantId();
            inOrder.verify(mockQuery).asc();

            inOrder = Mockito.inOrder(mockQuery);
            executeAndVerifySorting("tenantId", "desc", Status.OK);
            inOrder.verify(mockQuery).orderByTenantId();
            inOrder.verify(mockQuery).desc();
        }
Exemple #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSortingParameters()
        public virtual void testSortingParameters()
        {
            InOrder inOrder = Mockito.inOrder(queryMock);

            executeAndVerifySorting("batchId", "desc", Status.OK);
            inOrder.verify(queryMock).orderById();
            inOrder.verify(queryMock).desc();

            inOrder = Mockito.inOrder(queryMock);
            executeAndVerifySorting("batchId", "asc", Status.OK);
            inOrder.verify(queryMock).orderById();
            inOrder.verify(queryMock).asc();

            inOrder = Mockito.inOrder(queryMock);
            executeAndVerifySorting("startTime", "desc", Status.OK);
            inOrder.verify(queryMock).orderByStartTime();
            inOrder.verify(queryMock).desc();

            inOrder = Mockito.inOrder(queryMock);
            executeAndVerifySorting("startTime", "asc", Status.OK);
            inOrder.verify(queryMock).orderByStartTime();
            inOrder.verify(queryMock).asc();

            inOrder = Mockito.inOrder(queryMock);
            executeAndVerifySorting("endTime", "desc", Status.OK);
            inOrder.verify(queryMock).orderByEndTime();
            inOrder.verify(queryMock).desc();

            inOrder = Mockito.inOrder(queryMock);
            executeAndVerifySorting("endTime", "asc", Status.OK);
            inOrder.verify(queryMock).orderByEndTime();
            inOrder.verify(queryMock).asc();

            inOrder = Mockito.inOrder(queryMock);
            executeAndVerifySorting("tenantId", "desc", Status.OK);
            inOrder.verify(queryMock).orderByTenantId();
            inOrder.verify(queryMock).desc();

            inOrder = Mockito.inOrder(queryMock);
            executeAndVerifySorting("tenantId", "asc", Status.OK);
            inOrder.verify(queryMock).orderByTenantId();
            inOrder.verify(queryMock).asc();
        }
Exemple #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSortingParameters()
        public virtual void testSortingParameters()
        {
            InOrder inOrder = Mockito.inOrder(mockedQuery);

            executeAndVerifySuccessfulSorting("id", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByDeploymentId();
            inOrder.verify(mockedQuery).asc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySuccessfulSorting("id", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByDeploymentId();
            inOrder.verify(mockedQuery).desc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySuccessfulSorting("deploymentTime", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByDeploymentTime();
            inOrder.verify(mockedQuery).asc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySuccessfulSorting("deploymentTime", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByDeploymentTime();
            inOrder.verify(mockedQuery).desc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySuccessfulSorting("name", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByDeploymentName();
            inOrder.verify(mockedQuery).asc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySuccessfulSorting("name", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByDeploymentName();
            inOrder.verify(mockedQuery).desc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySuccessfulSorting("tenantId", "asc", Status.OK);
            inOrder.verify(mockedQuery).orderByTenantId();
            inOrder.verify(mockedQuery).asc();

            inOrder = Mockito.inOrder(mockedQuery);
            executeAndVerifySuccessfulSorting("tenantId", "desc", Status.OK);
            inOrder.verify(mockedQuery).orderByTenantId();
            inOrder.verify(mockedQuery).desc();
        }
Exemple #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldContinueMovingFilesIfUpgradeCancelledWhileMoving()
        {
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            string versionToMigrateTo   = upgradableDatabase.CurrentVersion();
            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(_databaseLayout).storeVersion();

            {
                // GIVEN
                StoreUpgrader upgrader       = NewUpgrader(upgradableDatabase, _allowMigrateConfig, pageCache);
                string        failureMessage = "Just failing";
                upgrader.AddParticipant(ParticipantThatWillFailWhenMoving(failureMessage));

                // WHEN
                try
                {
                    upgrader.MigrateIfNeeded(_databaseLayout);
                    fail("should have thrown");
                }
                catch (UnableToUpgradeException e)
                {                         // THEN
                    assertTrue(e.InnerException is IOException);
                    assertEquals(failureMessage, e.InnerException.Message);
                }
            }

            {
                // AND WHEN

                StoreUpgrader             upgrader             = NewUpgrader(upgradableDatabase, pageCache);
                StoreMigrationParticipant observingParticipant = Mockito.mock(typeof(StoreMigrationParticipant));
                upgrader.AddParticipant(observingParticipant);
                upgrader.MigrateIfNeeded(_databaseLayout);

                // THEN
                verify(observingParticipant, Mockito.never()).migrate(any(typeof(DatabaseLayout)), any(typeof(DatabaseLayout)), any(typeof(ProgressReporter)), eq(versionToMigrateFrom), eq(versionToMigrateTo));
                verify(observingParticipant, Mockito.times(1)).moveMigratedFiles(any(typeof(DatabaseLayout)), any(typeof(DatabaseLayout)), eq(versionToMigrateFrom), eq(versionToMigrateTo));

                verify(observingParticipant, Mockito.times(1)).cleanup(any(typeof(DatabaseLayout)));
            }
        }