private void deleteRel1( long rel, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long firstNode, long secondNode, int relType) throws IOException { ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>(); xaCon.getTransaction().relLoadProperties(rel, false, newPropertyReceiver(props)); int count = 0; for (int keyId : props.keySet()) { long id = props.get(keyId).other(); PropertyRecord record = pStore.getRecord(id); PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId()); DefinedProperty data = block.newPropertyData(pStore); if (data.propertyKeyId() == prop1.propertyKeyId()) { assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals("-string1", data.value()); } else if (data.propertyKeyId() == prop2.propertyKeyId()) { assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals(-1, data.value()); } else if (data.propertyKeyId() == prop3.propertyKeyId()) { assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals(false, data.value()); xaCon.getTransaction().relRemoveProperty(rel, prop3.propertyKeyId()); } else { throw new IOException(); } count++; } assertEquals(3, count); CountingPropertyReceiver propertyCounter = new CountingPropertyReceiver(); xaCon.getTransaction().relLoadProperties(rel, false, propertyCounter); assertEquals(3, propertyCounter.count); RelationshipRecord relData = xaCon.getTransaction().relLoadLight(rel); assertEquals(firstNode, relData.getFirstNode()); assertEquals(secondNode, relData.getSecondNode()); assertEquals(relType, relData.getType()); xaCon.getTransaction().relDelete(rel); MutableRelationshipLoadingPosition firstPos = getPosition(xaCon, firstNode); Iterator<RelationshipRecord> first = getMore(xaCon, firstNode, firstPos).iterator(); first.next(); MutableRelationshipLoadingPosition secondPos = getPosition(xaCon, secondNode); Iterator<RelationshipRecord> second = getMore(xaCon, secondNode, secondPos).iterator(); second.next(); assertTrue(first.hasNext()); assertTrue(second.hasNext()); }
private void validateRel2( long rel, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long firstNode, long secondNode, int relType) throws IOException { ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>(); xaCon.getTransaction().relLoadProperties(rel, false, newPropertyReceiver(props)); int count = 0; for (int keyId : props.keySet()) { long id = props.get(keyId).other(); PropertyRecord record = pStore.getRecord(id); PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId()); DefinedProperty data = block.newPropertyData(pStore); if (data.propertyKeyId() == prop1.propertyKeyId()) { assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals("string2", data.value()); xaCon.getTransaction().relChangeProperty(rel, prop1.propertyKeyId(), "-string2"); } else if (data.propertyKeyId() == prop2.propertyKeyId()) { assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals(2, data.value()); xaCon.getTransaction().relChangeProperty(rel, prop2.propertyKeyId(), new Integer(-2)); } else if (data.propertyKeyId() == prop3.propertyKeyId()) { assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals(false, data.value()); xaCon.getTransaction().relChangeProperty(rel, prop3.propertyKeyId(), true); } else { throw new IOException(); } count++; } assertEquals(3, count); RelationshipRecord relData = xaCon.getTransaction().relLoadLight(rel); assertEquals(firstNode, relData.getFirstNode()); assertEquals(secondNode, relData.getSecondNode()); assertEquals(relType, relData.getType()); }
private void validateNodeRel2( long node, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long rel1, long rel2, int relType1, int relType2) throws IOException { NodeRecord nodeRecord = xaCon.getTransaction().nodeLoadLight(node); assertTrue(nodeRecord != null); ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>(); xaCon.getTransaction().nodeLoadProperties(node, false, newPropertyReceiver(props)); int count = 0; for (int keyId : props.keySet()) { long id = props.get(keyId).other(); PropertyRecord record = pStore.getRecord(id); PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId()); DefinedProperty data = block.newPropertyData(pStore); if (data.propertyKeyId() == prop1.propertyKeyId()) { assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals("string2", data.value()); xaCon.getTransaction().nodeChangeProperty(node, prop1.propertyKeyId(), "-string2"); } else if (data.propertyKeyId() == prop2.propertyKeyId()) { assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals(2, data.value()); xaCon.getTransaction().nodeChangeProperty(node, prop2.propertyKeyId(), new Integer(-2)); } else if (data.propertyKeyId() == prop3.propertyKeyId()) { assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name()); assertEquals(false, data.value()); xaCon.getTransaction().nodeChangeProperty(node, prop3.propertyKeyId(), true); } else { throw new IOException(); } count++; } assertEquals(3, count); count = 0; MutableRelationshipLoadingPosition pos = getPosition(xaCon, node); while (true) { Iterable<RelationshipRecord> relData = getMore(xaCon, node, pos); if (!relData.iterator().hasNext()) { break; } for (RelationshipRecord rel : relData) { if (rel.getId() == rel1) { assertEquals(node, rel.getSecondNode()); assertEquals(relType1, rel.getType()); } else if (rel.getId() == rel2) { assertEquals(node, rel.getFirstNode()); assertEquals(relType2, rel.getType()); } else { throw new IOException(); } count++; } } assertEquals(2, count); }