@Override Representation convert( Object obj ) { return new RelationshipRepresentation( (Relationship) obj ); } };
@Mapping( "end" ) public ValueRepresentation endNodeUri() { return getDelegate().endNodeUri(); }
@Mapping( "type" ) public ValueRepresentation getType() { return getDelegate().getType(); }
RelationshipRepresentation representation = new RelationshipRepresentation( (Relationship) value ); representation.setTransactionStateChecker( checker ); write( format, representation );
@Mapping( "properties" ) public ValueRepresentation propertiesUri() { return getDelegate().propertiesUri(); }
@Mapping( "start" ) public ValueRepresentation startNodeUri() { return getDelegate().startNodeUri(); }
@Mapping( "property" ) public ValueRepresentation propertyUriTemplate() { return getDelegate().propertyUriTemplate(); }
@Override void extraData( MappingSerializer serializer ) { if ( !isDeleted() ) { MappingWriter properties = serializer.writer.newMapping( RepresentationType.PROPERTIES, "data" ); new PropertiesRepresentation( rel ).serialize( properties ); properties.done(); } }
@Override public String getIdentity() { return getDelegate().getIdentity(); }
@Test public void shouldStoreSuppliedPropertiesWhenCreatingRelationship() throws Exception { Map<String, Object> properties = new HashMap<>(); properties.put( "string", "value" ); properties.put( "integer", 17 ); long relId = actions.createRelationship( graphdbHelper.createNode(), graphdbHelper.createNode(), "LOVES", properties ) .getId(); try ( Transaction tx = database.getGraph().beginTx() ) { Relationship rel = database.getGraph().getRelationshipById( relId ); for ( String key : rel.getPropertyKeys() ) { assertTrue( "extra property stored", properties.containsKey( key ) ); } for ( Map.Entry<String, Object> entry : properties.entrySet() ) { assertEquals( entry.getValue(), rel.getProperty( entry.getKey() ) ); } } }
RelationshipRepresentation representation = new RelationshipRepresentation( (Relationship) value ); representation.setTransactionStateChecker( checker ); write( format, representation );
@Test public void shouldHavePropertiesLink() { assertUriMatches( RELATIONSHIP_URI_PATTERN + "/properties", relrep( 1234 ).propertiesUri() ); }
@Test public void shouldHaveStartNodeLink() { assertUriMatches( NODE_URI_PATTERN, relrep( 1234 ).startNodeUri() ); }
@Test public void shouldHavePropertyLinkTemplate() { assertUriMatches( RELATIONSHIP_URI_PATTERN + "/properties/\\{key\\}", relrep( 1234 ).propertyUriTemplate() ); }
@Mapping( "metadata" ) public MapRepresentation metadata() { if ( isDeleted() ) { return new MapRepresentation( map( "id", rel.getId(), "deleted", Boolean.TRUE ) ); } else { return new MapRepresentation( map( "id", rel.getId(), "type", rel.getType().name() ) ); } }
@Override public String getIdentity() { return getDelegate().getIdentity(); }
@Override protected Representation underlyingObjectToObject( Relationship relationship ) { return new RelationshipRepresentation( relationship ); } } );
@Test public void shouldHaveType() { assertNotNull( relrep( 1234 ).getType() ); }
@Test public void shouldHaveEndNodeLink() { assertUriMatches( NODE_URI_PATTERN, relrep( 1234 ).endNodeUri() ); }
@Mapping( "properties" ) public ValueRepresentation propertiesUri() { return getDelegate().propertiesUri(); }