@Override public boolean isEmpty() { return !entity.getPropertyKeys() .iterator() .hasNext(); }
private void formatProperties( PrintWriter out, PropertyContainer pc ) { if ( !pc.getPropertyKeys().iterator().hasNext() ) { return; } out.print( " " ); final String propertyString = formatProperties( pc ); out.print( propertyString ); }
@Override protected Iterable<String> manifest() { return propertyContainer.getPropertyKeys(); } };
private void ensureHasOnlyTheseProperties( PropertyContainer entity, Set<String> propertiesThatShouldExist ) { for ( String entityPropertyKey : entity.getPropertyKeys() ) { if ( !propertiesThatShouldExist.contains( entityPropertyKey ) ) { entity.removeProperty( entityPropertyKey ); } } }
PropertiesRep( PropertyContainer entity, long id ) { this.entityId = id; this.entityToString = entity.toString(); for ( String key : entity.getPropertyKeys() ) { Serializable value = (Serializable) entity.getProperty( key, null ); // We do this because the node may have changed since we did getPropertyKeys() if ( value != null ) { if ( value.getClass().isArray() ) { props.put( key, new ArrayList<>( Arrays.asList( IoPrimitiveUtils.asArray( value ) ) ) ); } else { props.put( key, value ); } } } }
private String formatProperties( PropertyContainer pc ) { StringBuilder result = new StringBuilder(); List<String> keys = Iterables.asList( pc.getPropertyKeys() ); Collections.sort( keys ); for ( String prop : keys ) { if ( result.length() > 0 ) { result.append( ", " ); } result.append( quote( prop ) ).append( ':' ); Object value = pc.getProperty( prop ); result.append( toString( value ) ); } return "{" + result + "}"; }
private void getAllProperties( PropertyContainer entity ) { for ( String key : entity.getPropertyKeys() ) { entity.getProperty( key ); } } };
private int readProperties( PropertyContainer entity ) { int count = 0; for ( String key : entity.getPropertyKeys() ) { entity.getProperty( key ); count++; } return count; }
static PropertyContainer container( Map<String, Object> values ) { PropertyContainer container = mock( PropertyContainer.class ); when( container.getPropertyKeys() ).thenReturn( values.keySet() ); when( container.getAllProperties() ).thenReturn( values ); for ( Map.Entry<String, Object> entry : values.entrySet() ) { when( container.getProperty( entry.getKey(), null ) ).thenReturn( entry.getValue() ); } return container; } }
private static <T extends PropertyContainer> T mockPropertyContainer( Class<T> type, Properties properties ) { T container = mock( type ); when( container.getProperty( anyString() ) ).thenAnswer( properties ); when( container.getProperty( anyString(), any() ) ).thenAnswer( properties ); when( container.getPropertyKeys() ).thenReturn( properties ); when( container.getAllProperties() ).thenReturn( properties.getProperties() ); return container; } }
@Override protected boolean matchesSafely( PropertyContainer propertyContainer, Description mismatchDescription ) { if ( !propertyContainer.hasProperty( propertyName ) ) { mismatchDescription.appendText( String.format( "found property container with property keys: %s", Iterables.asSet( propertyContainer.getPropertyKeys() ) ) ); return false; } return true; }
public static void assertProperties( Map<String, Object> properties, PropertyContainer entity ) { int count = 0; for ( String key : entity.getPropertyKeys() ) { Object expectedValue = properties.get( key ); Object entityValue = entity.getProperty( key ); if ( expectedValue.getClass().isArray() ) { assertTrue( Arrays.equals( (byte[]) expectedValue, (byte[]) entityValue ) ); } else { assertEquals( expectedValue, entityValue ); } count++; } assertEquals( properties.size(), count ); }
@Override public void clearGraph() { GraphDatabaseServiceCleaner.cleanDatabaseContent( db ); try ( Transaction tx = db.beginTx() ) { PropertyContainer graphProperties = graphProperties(); for ( String key : graphProperties.getPropertyKeys() ) { graphProperties.removeProperty( key ); } tx.success(); } }
public static void updateKeyTypes(Map<String, Class> keyTypes, PropertyContainer pc) { for (String prop : pc.getPropertyKeys()) { Object value = pc.getProperty(prop); Class storedClass = keyTypes.get(prop); if (storedClass==null) { keyTypes.put(prop,value.getClass()); continue; } if (storedClass == void.class || storedClass.equals(value.getClass())) continue; keyTypes.put(prop, void.class); } }
private int writeProps(XMLStreamWriter writer, PropertyContainer node) throws XMLStreamException { int count = 0; for (String prop : node.getPropertyKeys()) { Object value = node.getProperty(prop); writeData(writer, prop, value); count++; } return count; }
private void addProperties(Map<String, MetaResult> properties, String labelName, Iterable<ConstraintDefinition> constraints, Set<String> indexed, PropertyContainer pc, Node node) { for (String prop : pc.getPropertyKeys()) { if (properties.containsKey(prop)) continue; MetaResult res = metaResultForProp(pc, labelName, prop); res.elementType(Types.of(pc).name()); addSchemaInfo(res, prop, constraints, indexed, node); properties.put(prop,res); } }
private void updateKeyTypes(Map<String, Class> keyTypes, PropertyContainer pc) { for (String prop : pc.getPropertyKeys()) { Object value = pc.getProperty(prop); Class storedClass = keyTypes.get(prop); if (storedClass == null) { keyTypes.put(prop, value.getClass()); continue; } if (storedClass == void.class || storedClass.equals(value.getClass())) continue; keyTypes.put(prop, void.class); } }
private void ensureHasOnlyTheseProperties( PropertyContainer entity, Set<String> propertiesThatShouldExist ) { for ( String entityPropertyKey : entity.getPropertyKeys() ) { if ( !propertiesThatShouldExist.contains( entityPropertyKey ) ) { entity.removeProperty( entityPropertyKey ); } } }
public static Map<String, Object> getAllProperties(PropertyContainer propertyContainer) { Map<String, Object> properties = new HashMap<>(); for (String key : propertyContainer.getPropertyKeys()) { properties.put(key, propertyContainer.getProperty(key)); } return properties; } }
public Map<String, Object> getAllProperties(PropertyContainer propertyContainer) { Map<String, Object> properties = new HashMap<>(); for (String key : propertyContainer.getPropertyKeys()) { properties.put(key, toMapped(propertyContainer.getProperty(key))); } return properties; }