//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldMapDirectRelationship() public virtual void ShouldMapDirectRelationship() { // Given Node start, end; Relationship relationship; using (Transaction tx = Db.beginTx()) { start = Db.createNode(); end = Db.createNode(); relationship = start.CreateRelationshipTo(end, RelationshipType.withName("R")); tx.Success(); } RelationshipValue relationshipValue = VirtualValues.relationshipValue(relationship.Id, nodeValue(start.Id, Values.EMPTY_TEXT_ARRAY, EMPTY_MAP), nodeValue(start.Id, Values.EMPTY_TEXT_ARRAY, EMPTY_MAP), stringValue("R"), EMPTY_MAP); // When Relationship coreAPIRelationship = _mapper.mapRelationship(relationshipValue); // Then using (Transaction ignore = Db.beginTx()) { assertThat(coreAPIRelationship.Id, equalTo(relationship.Id)); assertThat(coreAPIRelationship.StartNode, equalTo(start)); assertThat(coreAPIRelationship.EndNode, equalTo(end)); } }
public override AnyValue MapRelationship(VirtualRelationshipValue value) { if (value is RelationshipValue) { // Note: we do not want to keep a reference to the whole relationship value as it could contain a lot of data. return(VirtualValues.relationship(value.Id())); } return(value); }
public override AnyValue MapNode(VirtualNodeValue value) { if (value is NodeValue) { // Note: we do not want to keep a reference to the whole node value as it could contain a lot of data. return(VirtualValues.node(value.Id())); } return(value); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void startDefaultTransaction() public virtual void StartDefaultTransaction() { CypherExecutor cypherExecutor = new CypherExecutor(_database, _logProvider); cypherExecutor.Start(); cypherExecutor.CreateTransactionContext(QUERY, VirtualValues.emptyMap(), _request); verify(_databaseQueryService).beginTransaction(KernelTransaction.Type.@implicit, AUTH_DISABLED); _logProvider.assertNoLoggingOccurred(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleLists() internal virtual void ShouldHandleLists() { // Given PrettyPrinter printer = new PrettyPrinter(); ListValue list = VirtualValues.list(stringValue("foo"), byteValue(( sbyte )42)); // When list.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("[\"foo\", 42]")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleNodeReference() internal virtual void ShouldHandleNodeReference() { // Given NodeReference node = VirtualValues.node(42L); PrettyPrinter printer = new PrettyPrinter(); // When node.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("(id=42)")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleEdgeValueWithoutLabelsNorProperties() internal virtual void ShouldHandleEdgeValueWithoutLabelsNorProperties() { // Given NodeValue node = VirtualValues.nodeValue(42L, Values.stringArray(), EMPTY_MAP); PrettyPrinter printer = new PrettyPrinter(); // When node.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("(id=42)")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleNodeValue() internal virtual void ShouldHandleNodeValue() { // Given NodeValue node = VirtualValues.nodeValue(42L, Values.stringArray("L1", "L2", "L3"), Props("foo", intValue(42), "bar", list(intValue(1337), stringValue("baz")))); PrettyPrinter printer = new PrettyPrinter(); // When node.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("(id=42 :L1:L2:L3 {bar: [1337, \"baz\"], foo: 42})")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleEdgeReference() internal virtual void ShouldHandleEdgeReference() { // Given RelationshipReference rel = VirtualValues.relationship(42L); PrettyPrinter printer = new PrettyPrinter(); // When rel.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("-[id=42]-")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleNodeValueWithoutProperties() internal virtual void ShouldHandleNodeValueWithoutProperties() { // Given NodeValue node = VirtualValues.nodeValue(42L, Values.stringArray("L1", "L2", "L3"), EMPTY_MAP); PrettyPrinter printer = new PrettyPrinter(); // When node.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("(id=42 :L1:L2:L3)")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleEdgeValueWithoutProperties() internal virtual void ShouldHandleEdgeValueWithoutProperties() { NodeValue startNode = VirtualValues.nodeValue(1L, Values.stringArray("L"), EMPTY_MAP); NodeValue endNode = VirtualValues.nodeValue(2L, Values.stringArray("L"), EMPTY_MAP); RelationshipValue rel = VirtualValues.relationshipValue(42L, startNode, endNode, stringValue("R"), EMPTY_MAP); PrettyPrinter printer = new PrettyPrinter(); // When rel.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("-[id=42 :R]-")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void startTransactionWithCustomTimeout() public virtual void StartTransactionWithCustomTimeout() { when(_request.getHeader(HttpHeaderUtils.MAX_EXECUTION_TIME_HEADER)).thenReturn(CUSTOM_TRANSACTION_TIMEOUT.ToString()); CypherExecutor cypherExecutor = new CypherExecutor(_database, _logProvider); cypherExecutor.Start(); cypherExecutor.CreateTransactionContext(QUERY, VirtualValues.emptyMap(), _request); verify(_databaseQueryService).beginTransaction(KernelTransaction.Type.@implicit, AUTH_DISABLED, CUSTOM_TRANSACTION_TIMEOUT, TimeUnit.MILLISECONDS); _logProvider.assertNoLoggingOccurred(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void startDefaultTransactionWhenHeaderHasIncorrectValue() public virtual void StartDefaultTransactionWhenHeaderHasIncorrectValue() { when(_request.getHeader(HttpHeaderUtils.MAX_EXECUTION_TIME_HEADER)).thenReturn("not a number"); CypherExecutor cypherExecutor = new CypherExecutor(_database, _logProvider); cypherExecutor.Start(); cypherExecutor.CreateTransactionContext(QUERY, VirtualValues.emptyMap(), _request); verify(_databaseQueryService).beginTransaction(KernelTransaction.Type.@implicit, AUTH_DISABLED); _logProvider.rawMessageMatcher().assertContains("Fail to parse `max-execution-time` header with value: 'not a number'. Should be a positive number."); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void startDefaultTransactionIfTimeoutIsNegative() public virtual void StartDefaultTransactionIfTimeoutIsNegative() { when(_request.getHeader(HttpHeaderUtils.MAX_EXECUTION_TIME_HEADER)).thenReturn("-2"); CypherExecutor cypherExecutor = new CypherExecutor(_database, _logProvider); cypherExecutor.Start(); cypherExecutor.CreateTransactionContext(QUERY, VirtualValues.emptyMap(), _request); verify(_databaseQueryService).beginTransaction(KernelTransaction.Type.@implicit, AUTH_DISABLED); _logProvider.assertNoLoggingOccurred(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandleEdgeValue() internal virtual void ShouldHandleEdgeValue() { // Given NodeValue startNode = VirtualValues.nodeValue(1L, Values.stringArray("L"), EMPTY_MAP); NodeValue endNode = VirtualValues.nodeValue(2L, Values.stringArray("L"), EMPTY_MAP); RelationshipValue rel = VirtualValues.relationshipValue(42L, startNode, endNode, stringValue("R"), Props("foo", intValue(42), "bar", list(intValue(1337), stringValue("baz")))); PrettyPrinter printer = new PrettyPrinter(); // When rel.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("-[id=42 :R {bar: [1337, \"baz\"], foo: 42}]-")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldHandlePaths() internal virtual void ShouldHandlePaths() { // Given NodeValue startNode = VirtualValues.nodeValue(1L, Values.stringArray("L"), EMPTY_MAP); NodeValue endNode = VirtualValues.nodeValue(2L, Values.stringArray("L"), EMPTY_MAP); RelationshipValue rel = VirtualValues.relationshipValue(42L, startNode, endNode, stringValue("R"), EMPTY_MAP); PathValue path = VirtualValues.path(new NodeValue[] { startNode, endNode }, new RelationshipValue[] { rel }); PrettyPrinter printer = new PrettyPrinter(); // When path.WriteTo(printer); // Then assertThat(printer.Value(), equalTo("(id=1 :L)-[id=42 :R]->(id=2 :L)")); }
private static MapValue TruncateParameters(MapValue parameters) { string[] keys = new string[parameters.Size()]; AnyValue[] values = new AnyValue[keys.Length]; int i = 0; foreach (string key in parameters.Keys) { keys[i] = key.Length <= _maxParameterKeyLength ? key : key.Substring(0, _maxParameterKeyLength); values[i] = parameters.Get(key).map(_valueTruncater); i++; } return(VirtualValues.map(keys, values)); }
private MapValue Props(params object[] keyValue) { string[] keys = new string[keyValue.Length / 2]; AnyValue[] values = new AnyValue[keyValue.Length / 2]; for (int i = 0; i < keyValue.Length; i++) { if (i % 2 == 0) { keys[i / 2] = ( string )keyValue[i]; } else { values[i / 2] = ( AnyValue )keyValue[i]; } } return(VirtualValues.map(keys, values)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldConvertValuesWithVirtualEntities() public virtual void ShouldConvertValuesWithVirtualEntities() { // Given ListValue nodeList = VirtualValues.list(NodeProxyValue, DirectNodeValue, NodeReference); ListValue expectedNodeList = VirtualValues.list(NodeProxyValue, DirectNodeValue, NodeProxyValue); ListValue relationshipList = VirtualValues.list(RelationshipProxyValue, DirectRelationshipValue, RelationshipReference); ListValue expectedRelationshipList = VirtualValues.list(RelationshipProxyValue, DirectRelationshipValue, RelationshipProxyValue); MapValue nodeMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { NodeProxyValue, DirectNodeValue, NodeReference }); MapValue expectedNodeMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { NodeProxyValue, DirectNodeValue, NodeProxyValue }); MapValue relationshipMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { RelationshipProxyValue, DirectRelationshipValue, RelationshipReference }); MapValue expectedRelationshipMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { RelationshipProxyValue, DirectRelationshipValue, RelationshipProxyValue }); ListValue nestedNodeList = VirtualValues.list(nodeList, nodeMap, NodeReference); ListValue expectedNestedNodeList = VirtualValues.list(expectedNodeList, expectedNodeMap, NodeProxyValue); ListValue nestedRelationshipList = VirtualValues.list(relationshipList, relationshipMap, RelationshipReference); ListValue expectedNestedRelationshipList = VirtualValues.list(expectedRelationshipList, expectedRelationshipMap, RelationshipProxyValue); MapValue nestedNodeMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { nodeList, nodeMap, nestedNodeList }); MapValue expectedNestedNodeMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { expectedNodeList, expectedNodeMap, expectedNestedNodeList }); MapValue nestedRelationshipMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { relationshipList, relationshipMap, nestedRelationshipList }); MapValue expectedNestedRelationshipMap = VirtualValues.map(new string[] { "a", "b", "c" }, new AnyValue[] { expectedRelationshipList, expectedRelationshipMap, expectedNestedRelationshipList }); // Verify VerifyConvertsValue(expectedNodeList, nodeList); VerifyConvertsValue(expectedRelationshipList, relationshipList); VerifyConvertsValue(expectedNodeMap, nodeMap); VerifyConvertsValue(expectedRelationshipMap, relationshipMap); VerifyConvertsValue(expectedNestedNodeList, nestedNodeList); VerifyConvertsValue(expectedNestedRelationshipList, nestedRelationshipList); VerifyConvertsValue(expectedNestedNodeMap, nestedNodeMap); VerifyConvertsValue(expectedNestedRelationshipMap, nestedRelationshipMap); }
internal RelationshipReference RelationshipReference = VirtualValues.relationship(11L); // Should equal relationshipProxyValue when converted //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotTouchValuesThatDoNotNeedConversion() public virtual void ShouldNotTouchValuesThatDoNotNeedConversion() { // Given ListValue nodeList = VirtualValues.list(NodeProxyValue, DirectNodeValue); ListValue relationshipList = VirtualValues.list(RelationshipProxyValue, DirectRelationshipValue); MapValue nodeMap = VirtualValues.map(new string[] { "a", "b" }, new AnyValue[] { NodeProxyValue, DirectNodeValue }); MapValue relationshipMap = VirtualValues.map(new string[] { "a", "b" }, new AnyValue[] { RelationshipProxyValue, DirectRelationshipValue }); // Verify VerifyDoesNotTouchValue(NodeProxyValue); VerifyDoesNotTouchValue(RelationshipProxyValue); VerifyDoesNotTouchValue(DirectNodeValue); VerifyDoesNotTouchValue(DirectRelationshipValue); VerifyDoesNotTouchValue(nodeList); VerifyDoesNotTouchValue(relationshipList); VerifyDoesNotTouchValue(nodeMap); VerifyDoesNotTouchValue(relationshipMap); // This is not an exhaustive test since the other cases are very uninteresting... VerifyDoesNotTouchValue(Values.booleanValue(false)); VerifyDoesNotTouchValue(Values.stringValue("Hello")); VerifyDoesNotTouchValue(Values.longValue(42L)); // ... }
private static MapValue SingletonMap(string key, object value) { return(VirtualValues.map(new string[] { key }, new AnyValue[] { ValueUtils.of(value) })); }
private void InitializeInstanceFields() { DirectRelationshipValue = VirtualValues.relationshipValue(12L, NodeProxyValue, DirectNodeValue, Values.stringValue("TYPE"), VirtualValues.emptyMap()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldDecodeBeginMessage() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldDecodeBeginMessage() { BeginMessage originalMessage = new BeginMessage(VirtualValues.map(new string[] { "tx_metadata", "tx_timeout" }, new AnyValue[] { EMPTY, longValue(10000) })); assertOriginalMessageEqualsToDecoded(originalMessage, _decoder); }