//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(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSimpleAuthorizationQuery() public virtual void testSimpleAuthorizationQuery() { IList <Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations(); AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations); Response response = given().queryParam("type", org.camunda.bpm.engine.authorization.Authorization_Fields.AUTH_TYPE_GLOBAL).then().expect().statusCode(Status.OK.StatusCode).when().get(SERVICE_PATH); InOrder inOrder = inOrder(mockQuery); inOrder.verify(mockQuery).authorizationType(org.camunda.bpm.engine.authorization.Authorization_Fields.AUTH_TYPE_GLOBAL); inOrder.verify(mockQuery).list(); string content = response.asString(); IList <string> instances = from(content).getList(""); Assert.assertEquals("There should be one authorization returned.", 1, instances.Count); Assert.assertNotNull("The returned authorization should not be null.", instances[0]); Authorization mockAuthorization = mockAuthorizations[0]; Assert.assertEquals(mockAuthorization.Id, from(content).getString("[0].id")); Assert.assertEquals(mockAuthorization.AuthorizationType, from(content).getInt("[0].type")); Assert.assertEquals(Permissions.READ.Name, from(content).getString("[0].permissions[0]")); Assert.assertEquals(Permissions.UPDATE.Name, from(content).getString("[0].permissions[1]")); Assert.assertEquals(mockAuthorization.UserId, from(content).getString("[0].userId")); Assert.assertEquals(mockAuthorization.GroupId, from(content).getString("[0].groupId")); Assert.assertEquals(mockAuthorization.ResourceType, from(content).getInt("[0].resourceType")); Assert.assertEquals(mockAuthorization.ResourceId, from(content).getString("[0].resourceId")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReportRetrieval() public virtual void testReportRetrieval() { Response response = given().then().expect().statusCode(Status.OK.StatusCode).contentType(ContentType.JSON).when().get(HISTORIC_REPORT_URL); // assert query invocation InOrder inOrder = Mockito.inOrder(historicBatchReport); inOrder.verify(historicBatchReport).list(); string content = response.asString(); IList <string> reportResults = from(content).getList(""); Assert.assertEquals("There should be two report results returned.", 2, reportResults.Count); Assert.assertNotNull(reportResults[0]); string returnedBatchType = from(content).getString("[0].batchType"); int returnedTTL = from(content).getInt("[0].historyTimeToLive"); long returnedFinishedCount = from(content).getLong("[0].finishedBatchesCount"); long returnedCleanableCount = from(content).getLong("[0].cleanableBatchesCount"); Assert.assertEquals(EXAMPLE_TYPE, returnedBatchType); Assert.assertEquals(EXAMPLE_TTL, returnedTTL); Assert.assertEquals(EXAMPLE_FINISHED_COUNT, returnedFinishedCount); Assert.assertEquals(EXAMPLE_CLEANABLE_COUNT, returnedCleanableCount); }
private string GetOrderDataCSV() { int countLines = 0; if (CurrentInOrder == null) { return(null); } StringBuilder sb = new StringBuilder(); // 17. Always access the data context with a new EF-Database-Instance because the Entities in the root workflow-node are in DETACHED-State! using (MyCompanyDB dbApp = new MyCompanyDB()) { InOrder inOrder = dbApp.InOrder.Include(c => c.InOrderPos_InOrder) .Include("InOrderPos_InOrder.Material") .Where(c => c.InOrderID == CurrentInOrder.InOrderID) .FirstOrDefault(); if (inOrder != null) { sb.AppendLine(String.Format("{0};{1};", inOrder.InOrderNo, inOrder.InOrderDate)); foreach (var line in inOrder.InOrderPos_InOrder) { countLines++; sb.AppendLine(String.Format("{0};{1};", line.Material.MaterialNo, line.TargetQuantity)); } } } using (ACMonitor.Lock(_20015_LockValue)) { _CountLines = countLines; } return(sb.ToString()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLockRelationshipsWhileReadingThem() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLockRelationshipsWhileReadingThem() { // given //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.helpers.collection.Visitor<org.neo4j.kernel.impl.api.index.EntityUpdates,Exception> visitor = mock(org.neo4j.helpers.collection.Visitor.class); Visitor <EntityUpdates, Exception> visitor = mock(typeof(Visitor)); StoreScan <Exception> storeScan = _storeView.visitRelationships(new int[] { _relTypeId }, id => id == _relPropertyKeyId, visitor); // when storeScan.Run(); // then assertThat("allocated locks: " + _lockMocks.Keys, _lockMocks.Count, greaterThanOrEqualTo(2)); Lock lock0 = _lockMocks[0L]; Lock lock1 = _lockMocks[1L]; assertNotNull("Lock[relationship=0] never acquired", lock0); assertNotNull("Lock[relationship=1] never acquired", lock1); InOrder order = inOrder(_locks, lock0, lock1); order.verify(_locks).acquireRelationshipLock(0, Org.Neo4j.Kernel.impl.locking.LockService_LockType.ReadLock); order.verify(lock0).release(); order.verify(_locks).acquireRelationshipLock(1, Org.Neo4j.Kernel.impl.locking.LockService_LockType.ReadLock); order.verify(lock1).release(); }
public async Task <IActionResult> Edit(int id, [Bind("IdinOrder,IdShippingCompany,IdSupplier,IdEmployee,Date")] InOrder inOrder) { if (id != inOrder.IdinOrder) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(inOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InOrderExists(inOrder.IdinOrder)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdEmployee"] = new SelectList(_context.Employee, "Idemployee", "Name", inOrder.IdEmployee); ViewData["IdShippingCompany"] = new SelectList(_context.ShippingCompany, "IdshippingCompany", "Nameocmpany", inOrder.IdShippingCompany); ViewData["IdSupplier"] = new SelectList(_context.Supplier, "Idsupplier", "Namesupplier", inOrder.IdSupplier); return(View(inOrder)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableInstanceRetrievalAsPost() public virtual void testVariableInstanceRetrievalAsPost() { string queryVariableName = "aVariableInstanceName"; IDictionary <string, string> queryParameter = new Dictionary <string, string>(); queryParameter["variableName"] = queryVariableName; Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(queryParameter).then().expect().statusCode(Status.OK.StatusCode).and().body("size()", @is(1)).body("[0].id", equalTo(mockInstanceBuilder.Id)).body("[0].name", equalTo(mockInstanceBuilder.Name)).body("[0].type", equalTo(VariableTypeHelper.toExpectedValueTypeName(mockInstanceBuilder.TypedValue.Type))).body("[0].value", equalTo(mockInstanceBuilder.TypedValue.Value)).body("[0].processInstanceId", equalTo(mockInstanceBuilder.ProcessInstanceId)).body("[0].executionId", equalTo(mockInstanceBuilder.ExecutionId)).body("[0].caseInstanceId", equalTo(mockInstanceBuilder.CaseInstanceId)).body("[0].caseExecutionId", equalTo(mockInstanceBuilder.CaseExecutionId)).body("[0].taskId", equalTo(mockInstanceBuilder.TaskId)).body("[0].activityInstanceId", equalTo(mockInstanceBuilder.ActivityInstanceId)).body("[0].tenantId", equalTo(mockInstanceBuilder.TenantId)).body("[0].errorMessage", equalTo(mockInstanceBuilder.ErrorMessage)).body("[0].serializedValue", nullValue()).when().post(VARIABLE_INSTANCE_QUERY_URL); // assert query invocation InOrder inOrder = Mockito.inOrder(mockedQuery); inOrder.verify(mockedQuery).variableName(queryVariableName); inOrder.verify(mockedQuery).list(); string content = response.asString(); IList <string> variables = from(content).getList(""); Assert.assertEquals("There should be one process definition returned.", 1, variables.Count); Assert.assertNotNull("There should be one process definition returned", variables[0]); verify(mockedQuery).disableBinaryFetching(); // requirement to not break existing API; should be: // verify(mockedQuery).disableCustomObjectDeserialization(); verify(mockedQuery, never()).disableCustomObjectDeserialization(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testFinishedHistoricActivityQueryAsPost() public virtual void testFinishedHistoricActivityQueryAsPost() { IDictionary <string, bool> body = new Dictionary <string, bool>(); body["finished"] = true; Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(body).then().expect().statusCode(Status.OK.StatusCode).when().post(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedQuery); inOrder.verify(mockedQuery).finished(); inOrder.verify(mockedQuery).list(); string content = response.asString(); IList <string> instances = from(content).getList(""); Assert.assertEquals("There should be one activity instance returned.", 1, instances.Count); Assert.assertNotNull("The returned activity instance should not be null.", instances[0]); string returnedProcessInstanceId = from(content).getString("[0].processInstanceId"); string returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId"); string returnedActivityEndTime = from(content).getString("[0].endTime"); Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId); Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId); Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_END_TIME, returnedActivityEndTime); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUnfinishedHistoricActivityQueryAsPost() public virtual void testUnfinishedHistoricActivityQueryAsPost() { IList <HistoricActivityInstance> mockedHistoricActivityInstances = MockProvider.createMockRunningHistoricActivityInstances(); HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(typeof(HistoricActivityInstanceQuery)); when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances); when(processEngine.HistoryService.createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery); IDictionary <string, bool> body = new Dictionary <string, bool>(); body["unfinished"] = true; Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(body).then().expect().statusCode(Status.OK.StatusCode).when().post(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedhistoricActivityInstanceQuery); inOrder.verify(mockedhistoricActivityInstanceQuery).unfinished(); inOrder.verify(mockedhistoricActivityInstanceQuery).list(); string content = response.asString(); IList <string> instances = from(content).getList(""); Assert.assertEquals("There should be one activity instance returned.", 1, instances.Count); Assert.assertNotNull("The returned activity instance should not be null.", instances[0]); string returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId"); string returnedActivityEndTime = from(content).getString("[0].endTime"); Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId); Assert.assertNull(returnedActivityEndTime); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testJobDefinitionRetrieval() public virtual void testJobDefinitionRetrieval() { string queryJobDefinitionId = "aJobDefId"; Response response = given().queryParam("jobDefinitionId", queryJobDefinitionId).then().expect().statusCode(Status.OK.StatusCode).when().get(JOB_DEFINITION_QUERY_URL); // assert query invocation InOrder inOrder = Mockito.inOrder(mockedQuery); inOrder.verify(mockedQuery).jobDefinitionId(queryJobDefinitionId); inOrder.verify(mockedQuery).list(); string content = response.asString(); IList <IDictionary <string, string> > jobDefinitions = from(content).getList(""); assertThat(jobDefinitions).hasSize(1); assertThat(jobDefinitions[0]).NotNull; string returnedId = from(content).getString("[0].id"); string returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId"); string returnedProcessDefinitionKey = from(content).getString("[0].processDefinitionKey"); string returnedActivityId = from(content).getString("[0].activityId"); string returnedJobType = from(content).getString("[0].jobType"); string returnedJobConfiguration = from(content).getString("[0].jobConfiguration"); bool returnedSuspensionState = from(content).getBoolean("[0].suspended"); long? returnedJobPriority = from(content).getObject("[0].overridingJobPriority", typeof(Long)); assertThat(returnedId).isEqualTo(MockProvider.EXAMPLE_JOB_DEFINITION_ID); assertThat(returnedProcessDefinitionId).isEqualTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); assertThat(returnedProcessDefinitionKey).isEqualTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); assertThat(returnedActivityId).isEqualTo(MockProvider.EXAMPLE_ACTIVITY_ID); assertThat(returnedJobType).isEqualTo(MockProvider.EXAMPLE_JOB_TYPE); assertThat(returnedJobConfiguration).isEqualTo(MockProvider.EXAMPLE_JOB_CONFIG); assertThat(returnedSuspensionState).isEqualTo(MockProvider.EXAMPLE_JOB_DEFINITION_IS_SUSPENDED); assertThat(returnedJobPriority).isEqualTo(MockProvider.EXAMPLE_JOB_DEFINITION_PRIORITY); }
/* * Tests that we unfreeze active transactions after commit and after apply of batch if batch length (in time) * is larger than safeZone time. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() { // GIVEN int maxBatchSize = 10; long idReuseSafeZoneTime = 100; Dependencies dependencies = mock(typeof(Dependencies)); TransactionObligationFulfiller fulfiller = mock(typeof(TransactionObligationFulfiller)); when(dependencies.ObligationFulfiller()).thenReturn(fulfiller); when(dependencies.LogService()).thenReturn(NullLogService.Instance); when(dependencies.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY); KernelTransactions kernelTransactions = mock(typeof(KernelTransactions)); when(dependencies.KernelTransactions()).thenReturn(kernelTransactions); TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess)); when(dependencies.CommitProcess()).thenReturn(commitProcess); TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, maxBatchSize, idReuseSafeZoneTime)); // WHEN int txCount = maxBatchSize; int doesNotMatter = 1; unpacker.UnpackResponse(new DummyTransactionResponse(doesNotMatter, txCount, idReuseSafeZoneTime + 1), NO_OP_TX_HANDLER); // THEN InOrder inOrder = inOrder(commitProcess, kernelTransactions); inOrder.verify(commitProcess, times(1)).commit(any(), any(), any()); inOrder.verify(kernelTransactions, times(1)).unblockNewTransactions(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPrioritiseCorrectly() public virtual void ShouldPrioritiseCorrectly() { BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance); NewEntry.Request newEntry = new NewEntry.Request(null, Content("")); AppendEntries.Request append = new AppendEntries.Request(_leader, 1, -1, -1, Entries(0, 0, 0), 0); AppendEntries.Request emptyAppend = new AppendEntries.Request(_leader, 1, -1, -1, RaftLogEntry.empty, 0); Heartbeat heartbeat = new Heartbeat(null, 0, 0, 0); batchHandler.Handle(Wrap(newEntry)); batchHandler.Handle(Wrap(append)); batchHandler.Handle(Wrap(heartbeat)); batchHandler.Handle(Wrap(emptyAppend)); verifyZeroInteractions(_downstreamHandler); // when batchHandler.Run(); batchHandler.Run(); batchHandler.Run(); batchHandler.Run(); // then InOrder inOrder = Mockito.inOrder(_downstreamHandler); inOrder.verify(_downstreamHandler).handle(Wrap(heartbeat)); inOrder.verify(_downstreamHandler).handle(Wrap(emptyAppend)); inOrder.verify(_downstreamHandler).handle(Wrap(append)); inOrder.verify(_downstreamHandler).handle(Wrap(new NewEntry.BatchRequest(singletonList(Content(""))))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeploymentRetrieval() public virtual void testDeploymentRetrieval() { InOrder inOrder = Mockito.inOrder(mockedQuery); string queryKey = "Name"; Response response = given().queryParam("nameLike", queryKey).then().expect().statusCode(Status.OK.StatusCode).when().get(DEPLOYMENT_QUERY_URL); // assert query invocation inOrder.verify(mockedQuery).deploymentNameLike(queryKey); inOrder.verify(mockedQuery).list(); string content = response.asString(); IList <string> deployments = from(content).getList(""); Assert.assertEquals("There should be one deployment returned.", 1, deployments.Count); Assert.assertNotNull("There should be one deployment returned", deployments[0]); string returnedId = from(content).getString("[0].id"); string returnedName = from(content).getString("[0].name"); string returnedSource = from(content).getString("[0].source"); string returnedDeploymentTime = from(content).getString("[0].deploymentTime"); Assert.assertEquals(MockProvider.EXAMPLE_DEPLOYMENT_ID, returnedId); Assert.assertEquals(MockProvider.EXAMPLE_DEPLOYMENT_NAME, returnedName); Assert.assertEquals(MockProvider.EXAMPLE_DEPLOYMENT_SOURCE, returnedSource); Assert.assertEquals(MockProvider.EXAMPLE_DEPLOYMENT_TIME, returnedDeploymentTime); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testIncludeInputsAndOutputs() public virtual void testIncludeInputsAndOutputs() { mockedQuery = setUpMockHistoricDecisionInstanceQuery(Collections.singletonList(MockProvider.createMockHistoricDecisionInstanceWithInputsAndOutputs())); string decisionDefinitionId = MockProvider.EXAMPLE_DECISION_DEFINITION_ID; Response response = given().queryParam("decisionDefinitionId", decisionDefinitionId).queryParam("includeInputs", true).queryParam("includeOutputs", true).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_DECISION_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedQuery); inOrder.verify(mockedQuery).decisionDefinitionId(decisionDefinitionId); inOrder.verify(mockedQuery).includeInputs(); inOrder.verify(mockedQuery).includeOutputs(); inOrder.verify(mockedQuery).list(); string content = response.asString(); IList <string> instances = from(content).getList(""); assertEquals(1, instances.Count); Assert.assertNotNull(instances[0]); IList <IDictionary <string, object> > returnedInputs = from(content).getList("[0].inputs"); IList <IDictionary <string, object> > returnedOutputs = from(content).getList("[0].outputs"); assertThat(returnedInputs, @is(notNullValue())); assertThat(returnedOutputs, @is(notNullValue())); verifyHistoricDecisionInputInstances(returnedInputs); verifyHistoricDecisionOutputInstances(returnedOutputs); }
//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(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExecuteStatements() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldExecuteStatements() { // given TransitionalPeriodTransactionMessContainer kernel = MockKernel(); QueryExecutionEngine executionEngine = mock(typeof(QueryExecutionEngine)); Result executionResult = mock(typeof(Result)); TransactionalContext transactionalContext = PrepareKernelWithQuerySession(kernel); when(executionEngine.ExecuteQuery("query", NoParams, transactionalContext)).thenReturn(executionResult); TransactionRegistry registry = mock(typeof(TransactionRegistry)); when(registry.Begin(any(typeof(TransactionHandle)))).thenReturn(1337L); TransactionHandle handle = GetTransactionHandle(kernel, executionEngine, registry); ExecutionResultSerializer output = mock(typeof(ExecutionResultSerializer)); // when handle.Execute(statements(new Statement("query", map(), false, (ResultDataContent[])null)), output, mock(typeof(HttpServletRequest))); // then verify(executionEngine).executeQuery("query", NoParams, transactionalContext); InOrder outputOrder = inOrder(output); outputOrder.verify(output).transactionCommitUri(uriScheme.txCommitUri(1337)); outputOrder.verify(output).statementResult(executionResult, false, ( ResultDataContent[] )null); outputOrder.verify(output).notifications(anyCollection()); outputOrder.verify(output).transactionStatus(anyLong()); outputOrder.verify(output).errors(argThat(HasNoErrors())); outputOrder.verify(output).finish(); verifyNoMoreInteractions(output); }
public virtual void TestOffSwitchSchedulingMultiLevelQueues() { // Setup queue configs SetupMultiLevelQueues(csConf); //B3 IDictionary <string, CSQueue> queues = new Dictionary <string, CSQueue>(); CSQueue root = CapacityScheduler.ParseQueue(csContext, csConf, null, CapacitySchedulerConfiguration .Root, queues, queues, TestUtils.spyHook); // Setup some nodes int memoryPerNode = 10; int coresPerNode = 10; int numNodes = 2; FiCaSchedulerNode node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, memoryPerNode * Gb); FiCaSchedulerNode node_1 = TestUtils.GetMockNode("host_1", DefaultRack, 0, memoryPerNode * Gb); Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource = Resources.CreateResource (numNodes * (memoryPerNode * Gb), numNodes * coresPerNode); Org.Mockito.Mockito.When(csContext.GetNumClusterNodes()).ThenReturn(numNodes); // Start testing LeafQueue b3 = (LeafQueue)queues[B3]; LeafQueue b2 = (LeafQueue)queues[B2]; // Simulate B3 returning a container on node_0 StubQueueAllocation(b2, clusterResource, node_0, 0 * Gb, NodeType.OffSwitch); StubQueueAllocation(b3, clusterResource, node_0, 1 * Gb, NodeType.OffSwitch); root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource )); VerifyQueueMetrics(b2, 0 * Gb, clusterResource); VerifyQueueMetrics(b3, 1 * Gb, clusterResource); // Now, B2 should get the scheduling opportunity since B2=0G/2G, B3=1G/7G // also, B3 gets a scheduling opportunity since B2 allocates RACK_LOCAL StubQueueAllocation(b2, clusterResource, node_1, 1 * Gb, NodeType.RackLocal); StubQueueAllocation(b3, clusterResource, node_1, 1 * Gb, NodeType.OffSwitch); root.AssignContainers(clusterResource, node_1, new ResourceLimits(clusterResource )); InOrder allocationOrder = Org.Mockito.Mockito.InOrder(b2, b3); allocationOrder.Verify(b2).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any <FiCaSchedulerNode>(), AnyResourceLimits()); allocationOrder.Verify(b3).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any <FiCaSchedulerNode>(), AnyResourceLimits()); VerifyQueueMetrics(b2, 1 * Gb, clusterResource); VerifyQueueMetrics(b3, 2 * Gb, clusterResource); // Now, B3 should get the scheduling opportunity // since B2 has 1/2G while B3 has 2/7G, // However, since B3 returns off-switch, B2 won't get an opportunity StubQueueAllocation(b2, clusterResource, node_0, 1 * Gb, NodeType.NodeLocal); StubQueueAllocation(b3, clusterResource, node_0, 1 * Gb, NodeType.OffSwitch); root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource )); allocationOrder = Org.Mockito.Mockito.InOrder(b3, b2); allocationOrder.Verify(b3).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any <FiCaSchedulerNode>(), AnyResourceLimits()); allocationOrder.Verify(b2).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any <FiCaSchedulerNode>(), AnyResourceLimits()); VerifyQueueMetrics(b2, 1 * Gb, clusterResource); VerifyQueueMetrics(b3, 3 * Gb, clusterResource); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCommitSinglePeriodicCommitStatement() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCommitSinglePeriodicCommitStatement() { // given string queryText = "USING PERIODIC COMMIT CREATE()"; TransitionalPeriodTransactionMessContainer kernel = MockKernel(); QueryExecutionEngine executionEngine = mock(typeof(QueryExecutionEngine)); Result executionResult = mock(typeof(Result)); TransactionalContext transactionalContext = PrepareKernelWithQuerySession(kernel); when(executionEngine.IsPeriodicCommit(queryText)).thenReturn(true); when(executionEngine.ExecuteQuery(eq(queryText), eq(NoParams), eq(transactionalContext))).thenReturn(executionResult); TransactionRegistry registry = mock(typeof(TransactionRegistry)); when(registry.Begin(any(typeof(TransactionHandle)))).thenReturn(1337L); TransactionHandle handle = GetTransactionHandle(kernel, executionEngine, registry); ExecutionResultSerializer output = mock(typeof(ExecutionResultSerializer)); Statement statement = new Statement(queryText, map(), false, (ResultDataContent[])null); // when handle.Commit(statements(statement), output, mock(typeof(HttpServletRequest))); // then verify(executionEngine).executeQuery(queryText, NoParams, transactionalContext); InOrder outputOrder = inOrder(output); outputOrder.verify(output).statementResult(executionResult, false, ( ResultDataContent[] )null); outputOrder.verify(output).notifications(anyCollectionOf(typeof(Notification))); outputOrder.verify(output).errors(argThat(HasNoErrors())); outputOrder.verify(output).finish(); verifyNoMoreInteractions(output); }
//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); executeAndVerifySorting("variableName", "asc", Status.OK); inOrder.verify(mockedQuery).orderByVariableName(); inOrder.verify(mockedQuery).asc(); inOrder = Mockito.inOrder(mockedQuery); executeAndVerifySorting("variableType", "desc", Status.OK); inOrder.verify(mockedQuery).orderByVariableType(); inOrder.verify(mockedQuery).desc(); inOrder = Mockito.inOrder(mockedQuery); executeAndVerifySorting("activityInstanceId", "asc", Status.OK); inOrder.verify(mockedQuery).orderByActivityInstanceId(); inOrder.verify(mockedQuery).asc(); inOrder = Mockito.inOrder(mockedQuery); executeAndVerifySorting("activityInstanceId", "desc", Status.OK); inOrder.verify(mockedQuery).orderByActivityInstanceId(); inOrder.verify(mockedQuery).desc(); inOrder = Mockito.inOrder(mockedQuery); executeAndVerifySorting("tenantId", "asc", Status.OK); inOrder.verify(mockedQuery).orderByTenantId(); inOrder.verify(mockedQuery).asc(); inOrder = Mockito.inOrder(mockedQuery); executeAndVerifySorting("tenantId", "desc", Status.OK); inOrder.verify(mockedQuery).orderByTenantId(); inOrder.verify(mockedQuery).desc(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRollbackTransactionAndTellRegistryToForgetItsHandle() public virtual void ShouldRollbackTransactionAndTellRegistryToForgetItsHandle() { // given TransitionalPeriodTransactionMessContainer kernel = MockKernel(); TransitionalTxManagementKernelTransaction transactionContext = kernel.NewTransaction(@explicit, AUTH_DISABLED, -1); TransactionRegistry registry = mock(typeof(TransactionRegistry)); when(registry.Begin(any(typeof(TransactionHandle)))).thenReturn(1337L); GraphDatabaseQueryService queryService = mock(typeof(GraphDatabaseQueryService)); TransactionHandle handle = new TransactionHandle(kernel, mock(typeof(QueryExecutionEngine)), queryService, registry, uriScheme, true, AUTH_DISABLED, anyLong(), NullLogProvider.Instance); ExecutionResultSerializer output = mock(typeof(ExecutionResultSerializer)); // when handle.Rollback(output); // then InOrder transactionOrder = inOrder(transactionContext, registry); transactionOrder.verify(transactionContext).rollback(); transactionOrder.verify(registry).forget(1337L); InOrder outputOrder = inOrder(output); outputOrder.verify(output).errors(argThat(HasNoErrors())); outputOrder.verify(output).finish(); verifyNoMoreInteractions(output); }
private void PrintNodes(Node node, InOrder order) { if (order == (int)InOrder.Ascending) { if (node.Left != null) { PrintNodes(node.Left, InOrder.Ascending); } Console.Write(node.Value + " "); if (node.Right != null) { PrintNodes(node.Right, InOrder.Ascending); } } else if (order == InOrder.Descending) { if (node.Right != null) { PrintNodes(node.Right, InOrder.Descending); } Console.Write(node.Value + " "); if (node.Left != null) { PrintNodes(node.Left, InOrder.Descending); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRollbackTransactionIfExecutionErrorOccurs() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRollbackTransactionIfExecutionErrorOccurs() { // given TransitionalPeriodTransactionMessContainer kernel = MockKernel(); TransitionalTxManagementKernelTransaction transactionContext = kernel.NewTransaction(@explicit, AUTH_DISABLED, -1); TransactionRegistry registry = mock(typeof(TransactionRegistry)); QueryExecutionEngine executionEngine = mock(typeof(QueryExecutionEngine)); TransactionalContext transactionalContext = PrepareKernelWithQuerySession(kernel); when(executionEngine.ExecuteQuery("query", NoParams, transactionalContext)).thenThrow(new System.NullReferenceException()); when(registry.Begin(any(typeof(TransactionHandle)))).thenReturn(1337L); TransactionHandle handle = GetTransactionHandle(kernel, executionEngine, registry); ExecutionResultSerializer output = mock(typeof(ExecutionResultSerializer)); // when handle.Execute(statements(new Statement("query", map(), false, (ResultDataContent[])null)), output, mock(typeof(HttpServletRequest))); // then verify(transactionContext).rollback(); verify(registry).forget(1337L); InOrder outputOrder = inOrder(output); outputOrder.verify(output).transactionCommitUri(uriScheme.txCommitUri(1337)); outputOrder.verify(output).errors(argThat(HasErrors(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.ExecutionFailed))); outputOrder.verify(output).finish(); verifyNoMoreInteractions(output); }
protected internal virtual void verifyQueryMockSorting(string sortBy, string sortOrder) { InOrder inOrder = inOrder(mockedQuery); if (sortBy.Equals(FilterQueryDto.SORT_BY_ID_VALUE)) { inOrder.verify(mockedQuery).orderByFilterId(); } else if (sortBy.Equals(FilterQueryDto.SORT_BY_RESOURCE_TYPE_VALUE)) { inOrder.verify(mockedQuery).orderByFilterResourceType(); } else if (sortBy.Equals(FilterQueryDto.SORT_BY_NAME_VALUE)) { inOrder.verify(mockedQuery).orderByFilterName(); } else if (sortBy.Equals(FilterQueryDto.SORT_BY_OWNER_VALUE)) { inOrder.verify(mockedQuery).orderByFilterOwner(); } if (sortOrder.Equals(AbstractQuery.SORTORDER_ASC)) { inOrder.verify(mockedQuery).asc(); } else if (sortOrder.Equals(AbstractQuery.SORTORDER_DESC)) { inOrder.verify(mockedQuery).desc(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogMessageIfCypherSyntaxErrorOccurs() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLogMessageIfCypherSyntaxErrorOccurs() { // given TransitionalPeriodTransactionMessContainer kernel = MockKernel(); QueryExecutionEngine executionEngine = mock(typeof(QueryExecutionEngine)); TransactionalContext transactionalContext = PrepareKernelWithQuerySession(kernel); when(executionEngine.ExecuteQuery("matsch (n) return n", NoParams, transactionalContext)).thenThrow(new QueryExecutionKernelException(new SyntaxException("did you mean MATCH?"))); TransactionRegistry registry = mock(typeof(TransactionRegistry)); when(registry.Begin(any(typeof(TransactionHandle)))).thenReturn(1337L); GraphDatabaseQueryService queryService = mock(typeof(GraphDatabaseQueryService)); TransactionHandle handle = new TransactionHandle(kernel, executionEngine, queryService, registry, uriScheme, false, AUTH_DISABLED, anyLong(), NullLogProvider.Instance); ExecutionResultSerializer output = mock(typeof(ExecutionResultSerializer)); // when Statement statement = new Statement("matsch (n) return n", map(), false, (ResultDataContent[])null); handle.Commit(statements(statement), output, mock(typeof(HttpServletRequest))); // then verify(registry).forget(1337L); InOrder outputOrder = inOrder(output); outputOrder.verify(output).errors(argThat(HasErrors(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.SyntaxError))); outputOrder.verify(output).finish(); verifyNoMoreInteractions(output); }
//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(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleExecutionEngineThrowingUndeclaredCheckedExceptions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleExecutionEngineThrowingUndeclaredCheckedExceptions() { // given QueryExecutionEngine executionEngine = mock(typeof(QueryExecutionEngine)); when(executionEngine.ExecuteQuery(eq("match (n) return n"), eq(NoParams), any(typeof(TransactionalContext)))).thenAnswer(invocationOnMock => { throw new Exception("BOO"); }); TransactionRegistry registry = mock(typeof(TransactionRegistry)); when(registry.Begin(any(typeof(TransactionHandle)))).thenReturn(1337L); GraphDatabaseQueryService queryService = mock(typeof(GraphDatabaseQueryService)); TransactionHandle handle = new TransactionHandle(MockKernel(), executionEngine, queryService, registry, uriScheme, false, AUTH_DISABLED, anyLong(), NullLogProvider.Instance); ExecutionResultSerializer output = mock(typeof(ExecutionResultSerializer)); // when Statement statement = new Statement("match (n) return n", map(), false, (ResultDataContent[])null); handle.Commit(statements(statement), output, mock(typeof(HttpServletRequest))); // then verify(registry).forget(1337L); InOrder outputOrder = inOrder(output); outputOrder.verify(output).statementResult(Null, eq(false), Null); outputOrder.verify(output).errors(argThat(HasErrors(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.ExecutionFailed))); outputOrder.verify(output).finish(); verifyNoMoreInteractions(output); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testExecutionRetrieval() public virtual void testExecutionRetrieval() { string queryKey = "key"; Response response = given().queryParam("processDefinitionKey", queryKey).then().expect().statusCode(Status.OK.StatusCode).when().get(EXECUTION_QUERY_URL); // assert query invocation InOrder inOrder = Mockito.inOrder(mockedQuery); inOrder.verify(mockedQuery).processDefinitionKey(queryKey); inOrder.verify(mockedQuery).list(); string content = response.asString(); IList <string> executions = from(content).getList(""); Assert.assertEquals("There should be one execution returned.", 1, executions.Count); Assert.assertNotNull("There should be one execution returned", executions[0]); string returnedExecutionId = from(content).getString("[0].id"); bool? returnedIsEnded = from(content).getBoolean("[0].ended"); string returnedProcessInstanceId = from(content).getString("[0].processInstanceId"); string returnedTenantId = from(content).getString("[0].tenantId"); Assert.assertEquals(MockProvider.EXAMPLE_EXECUTION_ID, returnedExecutionId); Assert.assertEquals(MockProvider.EXAMPLE_EXECUTION_IS_ENDED, returnedIsEnded); Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId); Assert.assertEquals(MockProvider.EXAMPLE_TENANT_ID, returnedTenantId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowStartingAPartBeforeCompletionOfMultiPartBuilder() public virtual void ShouldAllowStartingAPartBeforeCompletionOfMultiPartBuilder() { // given Indicator indicator = mock(typeof(Indicator)); ProgressMonitorFactory.MultiPartBuilder builder = Factory.mock(indicator, 10).multipleParts(TestName.MethodName); ProgressListener part1 = builder.ProgressForPart("part1", 1); ProgressListener part2 = builder.ProgressForPart("part2", 1); // when part1.Add(1); builder.Build(); part2.Add(1); part1.Done(); part2.Done(); // then InOrder order = inOrder(indicator); order.verify(indicator).startPart("part1", 1); order.verify(indicator).startProcess(2); order.verify(indicator).startPart("part2", 1); order.verify(indicator).completePart("part1"); order.verify(indicator).completePart("part2"); order.verify(indicator).completeProcess(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDecisionRequirementsDefinitionRetrieval() public virtual void testDecisionRequirementsDefinitionRetrieval() { Response response = given().then().expect().statusCode(Status.OK.StatusCode).when().get(DECISION_REQUIREMENTS_DEFINITION_QUERY_URL); // assert query invocation InOrder inOrder = Mockito.inOrder(mockedQuery); inOrder.verify(mockedQuery).list(); string content = response.asString(); IList <IDictionary <string, string> > decisionRequirementsDefinitions = from(content).getList(""); assertThat(decisionRequirementsDefinitions).hasSize(1); assertThat(decisionRequirementsDefinitions[0]).NotNull; string returnedId = from(content).getString("[0].id"); string returnedKey = from(content).getString("[0].key"); string returnedCategory = from(content).getString("[0].category"); string returnedName = from(content).getString("[0].name"); int returnedVersion = from(content).getInt("[0].version"); string returnedResource = from(content).getString("[0].resource"); string returnedDeploymentId = from(content).getString("[0].deploymentId"); string returnedTenantId = from(content).getString("[0].tenantId"); assertThat(returnedId).isEqualTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID); assertThat(returnedKey).isEqualTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY); assertThat(returnedCategory).isEqualTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_CATEGORY); assertThat(returnedName).isEqualTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_NAME); assertThat(returnedVersion).isEqualTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_VERSION); assertThat(returnedResource).isEqualTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_RESOURCE_NAME); assertThat(returnedDeploymentId).isEqualTo(MockProvider.EXAMPLE_DEPLOYMENT_ID); assertThat(returnedTenantId).isEqualTo(null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUnfinishedHistoricCaseActivityQuery() public virtual void testUnfinishedHistoricCaseActivityQuery() { IList <HistoricCaseActivityInstance> mockedHistoricCaseActivityInstances = MockProvider.createMockRunningHistoricCaseActivityInstances(); HistoricCaseActivityInstanceQuery mockedHistoricCaseActivityInstanceQuery = mock(typeof(HistoricCaseActivityInstanceQuery)); when(mockedHistoricCaseActivityInstanceQuery.list()).thenReturn(mockedHistoricCaseActivityInstances); when(processEngine.HistoryService.createHistoricCaseActivityInstanceQuery()).thenReturn(mockedHistoricCaseActivityInstanceQuery); Response response = given().queryParam("unfinished", true).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_CASE_ACTIVITY_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedHistoricCaseActivityInstanceQuery); inOrder.verify(mockedHistoricCaseActivityInstanceQuery).notEnded(); inOrder.verify(mockedHistoricCaseActivityInstanceQuery).list(); string content = response.asString(); IList <string> instances = from(content).getList(""); Assert.assertEquals(1, instances.Count); Assert.assertNotNull(instances[0]); string returnedCaseDefinitionId = from(content).getString("[0].caseDefinitionId"); string returnedActivityEndTime = from(content).getString("[0].endTime"); Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_ID, returnedCaseDefinitionId); Assert.assertNull(returnedActivityEndTime); }