private Predicate<ConstraintDefinition> relationshipPropertyExistenceFilter( final Set<String> propertyKeysSet ) { return item -> item.isConstraintType( ConstraintType.RELATIONSHIP_PROPERTY_EXISTENCE ) && propertyKeysSet.equals( Iterables.asSet( item.getPropertyKeys() ) ); }
private Predicate<ConstraintDefinition> propertyUniquenessFilter( final Set<String> propertyKeysSet ) { return item -> item.isConstraintType( ConstraintType.UNIQUENESS ) && propertyKeysSet.equals( Iterables.asSet( item.getPropertyKeys() ) ); }
private Predicate<ConstraintDefinition> nodePropertyExistenceFilter( final Set<String> propertyKeysSet ) { return item -> item.isConstraintType( ConstraintType.NODE_PROPERTY_EXISTENCE ) && propertyKeysSet.equals( Iterables.asSet( item.getPropertyKeys() ) ); }
public Representation getAllPropertyKeys() { Collection<ValueRepresentation> propKeys = Iterables.asSet( map( ValueRepresentation::string, graphDb.getAllPropertyKeys() ) ); return new ListRepresentation( RepresentationType.STRING, propKeys ); }
@Test public void test() { Set<Object> noIndexResult = Iterables.asSet( noIndexRun.get( currentValue ) ); Set<Object> constraintResult = Iterables.asSet( constraintRun.get( currentValue ) ); String errorMessage = currentValue.toString(); assertEquals( errorMessage, noIndexResult, constraintResult ); }
@Override protected boolean matchesSafely( Neo4jMatchers.Deferred<T> nodes, Description description ) { Set<T> expected = asSet( expectedObjects ); Set<T> found = Iterables.asSet( nodes.collection() ); if ( !expected.equals( found ) ) { description.appendText( "found " + found.toString() ); return false; } return true; }
@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 boolean dropPropertyUniquenessConstraint( String labelName, Iterable<String> propertyKeys ) { final Set<String> propertyKeysSet = Iterables.asSet( propertyKeys ); ConstraintDefinition constraint = Iterables.singleOrNull( filteredNodeConstraints( labelName, propertyUniquenessFilter( propertyKeysSet ) ) ); if ( constraint != null ) { constraint.drop(); } return constraint != null; }
public boolean dropRelationshipPropertyExistenceConstraint( String typeName, Iterable<String> propertyKeys ) { final Set<String> propertyKeysSet = Iterables.asSet( propertyKeys ); ConstraintDefinition constraint = Iterables.singleOrNull( filteredRelationshipConstraints( typeName, relationshipPropertyExistenceFilter( propertyKeysSet ) ) ); if ( constraint != null ) { constraint.drop(); } return constraint != null; }
@Override protected boolean matchesSafely( Neo4jMatchers.Deferred<T> nodes, Description description ) { Set<T> expected = asSet( expectedObjects ); Set<T> found = Iterables.asSet( nodes.collection() ); if ( !found.containsAll( expected ) ) { description.appendText( "found " + found.toString() ); return false; } return true; }
public boolean dropNodePropertyExistenceConstraint( String labelName, Iterable<String> propertyKeys ) { final Set<String> propertyKeysSet = Iterables.asSet( propertyKeys ); ConstraintDefinition constraint = Iterables.singleOrNull( filteredNodeConstraints( labelName, nodePropertyExistenceFilter( propertyKeysSet ) ) ); if ( constraint != null ) { constraint.drop(); } return constraint != null; }
public ListRepresentation getAllLabels( boolean inUse ) { ResourceIterable<Label> labels = inUse ? graphDb.getAllLabelsInUse() : graphDb.getAllLabels(); Collection<ValueRepresentation> labelNames = Iterables.asSet( map( label -> ValueRepresentation.string( label.name() ), labels ) ); return new ListRepresentation( RepresentationType.STRING, labelNames ); }
private void assertExpectedRelationshipTypes( Set<String> expectedTypes, Node node, boolean commit ) { Set<String> actual = Iterables.asSet( asStrings( node.getRelationshipTypes() ) ); assertEquals( expectedTypes, actual ); if ( commit ) { newTransaction(); } assertEquals( expectedTypes, Iterables.asSet( asStrings( node.getRelationshipTypes() ) ) ); }
@Test public void should_construct_schema_cache() { // GIVEN Collection<SchemaRule> rules = asList( hans, witch, gretel, robot ); SchemaCache cache = new SchemaCache( new ConstraintSemantics(), rules, IndexProviderMap.EMPTY ); // THEN assertEquals( asSet( hans, gretel ), Iterables.asSet( cache.indexDescriptors() ) ); assertEquals( asSet( witch, robot ), Iterables.asSet( cache.constraintRules() ) ); }
@Test public void shouldGetRelationships() { // GIVEN BatchInserter inserter = globalInserter; long node = inserter.createNode( null ); createRelationships( inserter, node, RelTypes.REL_TYPE1, 3 ); createRelationships( inserter, node, RelTypes.REL_TYPE2, 4 ); // WHEN Set<Long> gottenRelationships = Iterables.asSet( inserter.getRelationshipIds( node ) ); // THEN assertEquals( 21, gottenRelationships.size() ); }
@Test public void shouldGetNodeLabels() { // GIVEN BatchInserter inserter = globalInserter; long node = inserter.createNode( map(), Labels.FIRST, Labels.THIRD ); // WHEN Iterable<String> labelNames = asNames( inserter.getNodeLabels( node ) ); // THEN assertEquals( asSet( Labels.FIRST.name(), Labels.THIRD.name() ), Iterables.asSet( labelNames ) ); }
@Test public void shouldReplaceExistingInlinedLabelsWithDynamic() { // GIVEN BatchInserter inserter = globalInserter; long node = inserter.createNode( map(), Labels.FIRST ); // WHEN Pair<Label[], Set<String>> labels = manyLabels( 100 ); inserter.setNodeLabels( node, labels.first() ); // THEN Iterable<String> labelNames = asNames( inserter.getNodeLabels( node ) ); assertEquals( labels.other(), Iterables.asSet( labelNames ) ); }
@Test public void shouldReplaceExistingDynamicLabelsWithInlined() { // GIVEN BatchInserter inserter = globalInserter; long node = inserter.createNode( map(), manyLabels( 150 ).first() ); // WHEN inserter.setNodeLabels( node, Labels.FIRST ); // THEN Iterable<String> labelNames = asNames( inserter.getNodeLabels( node ) ); assertEquals( asSet( Labels.FIRST.name() ), Iterables.asSet( labelNames ) ); }