//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void roundingErrorsFromLongToDoubleShouldNotPreventTxFromCommitting() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RoundingErrorsFromLongToDoubleShouldNotPreventTxFromCommitting() { // Given // a node with a constrained label and a long value long propertyValue = 285414114323346805L; long firstNode = ConstrainedNode("label1", "key1", propertyValue); Transaction transaction = NewTransaction(AnonymousContext.writeToken()); long node = CreateLabeledNode(transaction, "label1"); assertNotEquals(firstNode, node); // When // a new node with the same constraint is added, with a value not equal but which would be mapped to the same double propertyValue++; // note how propertyValue is definitely not equal to propertyValue++ but they do equal if they are cast to double int propertyKeyId = transaction.TokenWrite().propertyKeyGetOrCreateForName("key1"); transaction.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of(propertyValue)); // Then // the commit should still succeed Commit(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: long createEntity(org.neo4j.internal.kernel.api.Transaction transaction, String type, String property, String value) throws Exception internal override long CreateEntity(Transaction transaction, string type, string property, string value) { long node = CreateEntity(transaction, type); int propertyKey = transaction.TokenWrite().propertyKeyGetOrCreateForName(property); transaction.DataWrite().nodeSetProperty(node, propertyKey, Values.of(value)); return(node); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private long createLabeledNode(org.neo4j.internal.kernel.api.Transaction transaction, String label, String key, Object value) throws org.neo4j.internal.kernel.api.exceptions.KernelException private long CreateLabeledNode(Transaction transaction, string label, string key, object value) { long node = CreateLabeledNode(transaction, label); int propertyKeyId = transaction.TokenWrite().propertyKeyGetOrCreateForName(key); transaction.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of(value)); return(node); }
private void AssertCanEncodeAndDecodeToSameValue(object value, int payloadSize) { PropertyBlock target = new PropertyBlock(); bool encoded = ShortArray.encode(0, value, target, payloadSize); assertTrue(encoded); assertEquals(Values.of(value), ShortArray.decode(target)); }
private static Value[] ToValues(object[] objects) { Value[] values = new Value[objects.Length]; for (int i = 0; i < objects.Length; i++) { object @object = objects[i]; values[i] = @object is Value ? ( Value )@object : Values.of(@object); } return(values); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAddOrRemoveFromIndexForNonAutoIndexedProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAddOrRemoveFromIndexForNonAutoIndexedProperty() { // Given _index.startAutoIndexingProperty(_indexedPropertyName); // When _index.propertyChanged(_ops, 11, _nonIndexedProperty, Values.of("Goodbye!"), Values.of("Hello!")); // Then verifyZeroInteractions(_ops); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIncludePropertyRecordSize() public virtual void ShouldIncludePropertyRecordSize() { // given PropertyValueRecordSizeCalculator calculator = NewCalculator(); // when int size = calculator.ApplyAsInt(new Value[] { Values.of(10) }); // then assertEquals(PropertyRecordFormat.RECORD_SIZE, size); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIncludeDynamicRecordSizes() public virtual void ShouldIncludeDynamicRecordSizes() { // given PropertyValueRecordSizeCalculator calculator = NewCalculator(); // when int size = calculator.ApplyAsInt(new Value[] { Values.of(String(80)), Values.of(new string[] { String(150) }) }); // then assertEquals(_propertyRecordSize + DYNAMIC_RECORD_SIZE + DYNAMIC_RECORD_SIZE * 2, size); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIgnoreInlinedUnchangedProperty() public virtual void ShouldIgnoreInlinedUnchangedProperty() { // GIVEN int key = 10; Value value = Values.of(12341); PropertyRecord before = PropertyRecord(Property(key, value)); PropertyRecord after = PropertyRecord(Property(key, value)); // WHEN assertThat(Convert(_none, _none, Change(before, after)), equalTo(EntityUpdates.ForEntity(0, false).build())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSpanMultiplePropertyRecords() public virtual void ShouldSpanMultiplePropertyRecords() { // given PropertyValueRecordSizeCalculator calculator = NewCalculator(); // when int size = calculator.ApplyAsInt(new Value[] { Values.of(10), Values.of("test"), Values.of(( sbyte )5), Values.of(String(80)), Values.of("a bit longer short string"), Values.of(1234567890123456789L), Values.of(5), Values.of("value") }); // then assertEquals(_propertyRecordSize * 3 + DYNAMIC_RECORD_SIZE, size); }
public static void AssertEqualsMaybeNull <T>(object o1, object o2, T entity, string key) where T : Org.Neo4j.Graphdb.PropertyContainer { string entityDescription = "For " + entity + " and " + key; if (o1 == null || o2 == null) { assertSame(entityDescription + ". " + Strings.prettyPrint(o1) + " != " + Strings.prettyPrint(o2), o1, o2); } else { assertEquals(entityDescription, Values.of(o1), Values.of(o2)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotReportConflictOnSameValueSameEntityId() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotReportConflictOnSameValueSameEntityId() { // given Value value = Values.of(123); long entityId = 10; // when NativeIndexValue merged = _detector.merge(Key(entityId, value), Key(entityId, value), NativeIndexValue.Instance, NativeIndexValue.Instance); // then assertNull(merged); _detector.checkConflict(array()); // <-- should not throw conflict exception }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowRemoveAndAddConflictingDataInOneTransaction_ChangeProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowRemoveAndAddConflictingDataInOneTransactionChangeProperty() { // given long node = ConstrainedNode("Label1", "key1", "value1"); Transaction transaction = NewTransaction(AnonymousContext.writeToken()); // when int propertyKeyId = transaction.TokenWrite().propertyKeyGetOrCreateForName("key1"); transaction.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of("value2")); CreateLabeledNode(transaction, "Label1", "key1", "value1"); Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowNoopPropertyUpdate() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowNoopPropertyUpdate() { // given long entity = CreateConstraintAndEntity("Type1", "key1", "value1"); Transaction transaction = NewTransaction(AnonymousContext.writeToken()); // when int key = transaction.TokenWrite().propertyKeyGetOrCreateForName("key1"); SetProperty(transaction.DataWrite(), entity, key, Values.of("value1")); // then should not throw exception }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowNoopPropertyUpdate() throws org.neo4j.internal.kernel.api.exceptions.KernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowNoopPropertyUpdate() { // given long node = ConstrainedNode("Label1", "key1", "value1"); Transaction transaction = NewTransaction(AnonymousContext.writeToken()); // when int key = transaction.TokenWrite().propertyKeyGetOrCreateForName("key1"); transaction.DataWrite().nodeSetProperty(node, key, Values.of("value1")); // then should not throw exception Commit(); }
private void CreateRecordIn <RECORD>(RecordStore <RECORD> store) where RECORD : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord { RECORD record = store.NewRecord(); record.Id = store.nextId(); record.InUse = true; if (record is PropertyRecord) { // Special hack for property store, since it's not enough to simply set a record as in use there PropertyBlock block = new PropertyBlock(); (( PropertyStore )store).encodeValue(block, 0, Values.of(10)); (( PropertyRecord )record).addPropertyBlock(block); } store.UpdateRecord(record); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowTemporaryViolationsWithinTransactions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowTemporaryViolationsWithinTransactions() { // given long entity = CreateConstraintAndEntity("Type1", "key1", "value1"); Transaction transaction = NewTransaction(AnonymousContext.writeToken()); // when int key = transaction.TokenWrite().propertyKeyGetOrCreateForName("key1"); //remove and put back RemoveProperty(transaction.DataWrite(), entity, key); SetProperty(transaction.DataWrite(), entity, key, Values.of("value2")); Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLookupProperty() throws org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLookupProperty() { // given long nodeId = 10; Value value = Values.of("abc"); int propertyKeyId = 0; StubNodeCursor nodeCursor = (new StubNodeCursor()).withNode(nodeId, new long[] {}, genericMap(999, Values.of(12345), propertyKeyId, value)); CursorPropertyAccessor accessor = new CursorPropertyAccessor(nodeCursor, new StubPropertyCursor(), new StubRead()); // when Value readValue = accessor.GetNodePropertyValue(nodeId, propertyKeyId); // then assertEquals(value, readValue); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private long constrainedNode(String labelName, String propertyKey, Object propertyValue) throws org.neo4j.internal.kernel.api.exceptions.KernelException private long ConstrainedNode(string labelName, string propertyKey, object propertyValue) { long node; { Transaction transaction = NewTransaction(AnonymousContext.writeToken()); int label = transaction.TokenWrite().labelGetOrCreateForName(labelName); node = transaction.DataWrite().nodeCreate(); transaction.DataWrite().nodeAddLabel(node, label); int key = transaction.TokenWrite().propertyKeyGetOrCreateForName(propertyKey); transaction.DataWrite().nodeSetProperty(node, key, Values.of(propertyValue)); Commit(); } CreateConstraint(labelName, propertyKey); return(node); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldConvertInlinedRemovedProperty() public virtual void ShouldConvertInlinedRemovedProperty() { // GIVEN int key = 10; Value value = Values.of(12341); PropertyRecord before = PropertyRecord(Property(key, value)); PropertyRecord after = PropertyRecord(); // WHEN EntityUpdates update = Convert(_none, _none, Change(before, after)); // THEN EntityUpdates expected = EntityUpdates.ForEntity(0, false).removed(key, value).build(); assertEquals(expected, update); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: long createConstraintAndEntity(String type, String property, String value) throws Exception internal override long CreateConstraintAndEntity(string type, string property, string value) { Transaction transaction = NewTransaction(AnonymousContext.writeToken()); int label = transaction.TokenWrite().labelGetOrCreateForName(type); long node = transaction.DataWrite().nodeCreate(); transaction.DataWrite().nodeAddLabel(node, label); int propertyKey = transaction.TokenWrite().propertyKeyGetOrCreateForName(property); transaction.DataWrite().nodeSetProperty(node, propertyKey, Values.of(value)); Commit(); CreateConstraint(type, property); return(node); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void changedShouldRetainValues() public virtual void ChangedShouldRetainValues() { Value singleAfter = Values.of("Hello"); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: IndexEntryUpdate<?> singleChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4), singleValue, singleAfter); IndexEntryUpdate <object> singleChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4), _singleValue, singleAfter); Value[] multiAfter = new Value[] { Values.of("Hello"), Values.of("Hi") }; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: IndexEntryUpdate<?> multiChange = IndexEntryUpdate.change(0, org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel(3, 4, 5), multiValue, multiAfter); IndexEntryUpdate <object> multiChange = IndexEntryUpdate.Change(0, SchemaDescriptorFactory.forLabel(3, 4, 5), _multiValue, multiAfter); assertThat(new object[] { _singleValue }, equalTo(singleChange.BeforeValues())); assertThat(new object[] { singleAfter }, equalTo(singleChange.Values())); assertThat(_multiValue, equalTo(multiChange.BeforeValues())); assertThat(multiAfter, equalTo(multiChange.Values())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTreatPropertyThatMovedToAnotherRecordAsChange() public virtual void ShouldTreatPropertyThatMovedToAnotherRecordAsChange() { // GIVEN int key = 12; Value oldValue = Values.of("value1"); Value newValue = Values.of("value two"); Command.PropertyCommand movedFrom = Change(PropertyRecord(Property(key, oldValue)), PropertyRecord()); Command.PropertyCommand movedTo = Change(PropertyRecord(), PropertyRecord(Property(key, newValue))); // WHEN EntityUpdates update = Convert(_none, _none, movedFrom, movedTo); // THEN EntityUpdates expected = EntityUpdates.ForEntity(0, false).changed(key, oldValue, newValue).build(); assertEquals(expected, update); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemoveSpecificValueFromIndexForAutoIndexedProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRemoveSpecificValueFromIndexForAutoIndexedProperty() { // Given long nodeId = 11; int value1 = 1; int value2 = 2; _index.startAutoIndexingProperty(_indexedPropertyName); _index.startAutoIndexingProperty(_indexedPropertyName2); _index.propertyAdded(_ops, nodeId, _indexedProperty, Values.of(value1)); _index.propertyAdded(_ops, nodeId, _indexedProperty2, Values.of(value2)); // When reset(_ops); _index.propertyRemoved(_ops, nodeId, _indexedProperty); // Then verify(_ops).nodeRemoveFromExplicitIndex(NODE_AUTO_INDEX, nodeId, _indexedPropertyName); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemoveReSetAndTwiceRemovePropertyOnNode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRemoveReSetAndTwiceRemovePropertyOnNode() { // given long node = CreateNodeWithProperty(PROPERTY_KEY, "bar"); // when using (Transaction tx = beginTransaction()) { int prop = tx.Token().propertyKeyGetOrCreateForName(PROPERTY_KEY); tx.DataWrite().nodeRemoveProperty(node, prop); tx.DataWrite().nodeSetProperty(node, prop, Values.of("bar")); tx.DataWrite().nodeRemoveProperty(node, prop); tx.DataWrite().nodeRemoveProperty(node, prop); tx.Success(); } // then AssertNoProperty(node, PROPERTY_KEY); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnEntityNotFound() public virtual void ShouldThrowOnEntityNotFound() { // given long nodeId = 10; Value value = Values.of("abc"); int propertyKeyId = 0; StubNodeCursor nodeCursor = (new StubNodeCursor()).withNode(nodeId, new long[] {}, genericMap(999, Values.of(12345), propertyKeyId, value)); CursorPropertyAccessor accessor = new CursorPropertyAccessor(nodeCursor, new StubPropertyCursor(), new StubRead()); // when try { accessor.GetNodePropertyValue(nodeId + 1, propertyKeyId); fail(); } catch (EntityNotFoundException) { // then good } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportInTransactionNodeProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReportInTransactionNodeProperty() { // GIVEN long node; int p1, p2, p3, p4, p5; using (Transaction tx = beginTransaction()) { node = tx.DataWrite().nodeCreate(); p1 = tx.TokenWrite().propertyKeyCreateForName("p1"); p2 = tx.TokenWrite().propertyKeyCreateForName("p2"); p3 = tx.TokenWrite().propertyKeyCreateForName("p3"); p4 = tx.TokenWrite().propertyKeyCreateForName("p4"); p5 = tx.TokenWrite().propertyKeyCreateForName("p5"); tx.DataWrite().nodeSetProperty(node, p1, Values.of(1)); tx.DataWrite().nodeSetProperty(node, p3, Values.of(3)); tx.DataWrite().nodeSetProperty(node, p4, Values.of(4)); tx.Success(); } using (Transaction tx = beginTransaction()) { // WHEN tx.DataWrite().nodeSetProperty(node, p3, Values.of(13)); tx.DataWrite().nodeRemoveProperty(node, p4); tx.DataWrite().nodeSetProperty(node, p5, Values.of(15)); // THEN assertNull("Unchanged existing property is null", tx.DataRead().nodePropertyChangeInTransactionOrNull(node, p1)); assertNull("Unchanged missing property is null", tx.DataRead().nodePropertyChangeInTransactionOrNull(node, p2)); assertEquals("Changed property is new value", Values.of(13), tx.DataRead().nodePropertyChangeInTransactionOrNull(node, p3)); assertEquals("Removed property is NO_VALUE", Values.NO_VALUE, tx.DataRead().nodePropertyChangeInTransactionOrNull(node, p4)); assertEquals("Added property is new value", Values.of(15), tx.DataRead().nodePropertyChangeInTransactionOrNull(node, p5)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportConflictOnSameValueAndDifferentEntityIds() public virtual void ShouldReportConflictOnSameValueAndDifferentEntityIds() { // given Value value = Values.of(123); long entityId1 = 10; long entityId2 = 20; // when NativeIndexValue merged = _detector.merge(Key(entityId1, value), Key(entityId2, value), NativeIndexValue.Instance, NativeIndexValue.Instance); // then assertNull(merged); try { _detector.checkConflict(array(value)); fail("Should've detected conflict"); } catch (IndexEntryConflictException e) { assertEquals(entityId1, e.ExistingNodeId); assertEquals(entityId2, e.AddedNodeId); assertEquals(value, e.SinglePropertyValue); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldEnforceOnSetProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldEnforceOnSetProperty() { // given ConstrainedNode("Label1", "key1", "value1"); Transaction transaction = NewTransaction(AnonymousContext.writeToken()); // when long node = CreateLabeledNode(transaction, "Label1"); try { int propertyKeyId = transaction.TokenWrite().propertyKeyGetOrCreateForName("key1"); transaction.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of("value1")); fail("should have thrown exception"); } // then catch (UniquePropertyValueValidationException e) { assertThat(e.GetUserMessage(TokenLookup(transaction)), containsString("`key1` = 'value1'")); } Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnNoValueOnMissingProperty() throws org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturnNoValueOnMissingProperty() { // given long nodeId = 10; StubNodeCursor nodeCursor = (new StubNodeCursor()).withNode(nodeId, new long[] {}, genericMap(999, Values.of(12345))); CursorPropertyAccessor accessor = new CursorPropertyAccessor(nodeCursor, new StubPropertyCursor(), new StubRead()); // when Value readValue = accessor.GetNodePropertyValue(nodeId, 0); // then assertEquals(NO_VALUE, readValue); }