Refine search
@Test public void testRemove() { // WHEN diffSets.add( 1L ); diffSets.remove( 2L ); // THEN assertEquals( asSet( 1L ), diffSets.getAdded() ); assertEquals( asSet( 2L ), diffSets.getRemoved() ); }
@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() ) ); }
public Consumer<Map<String, Object>> assertABAB(Map<String, PropertyContainer> pcs) { return (row) -> { Map<String, List<PropertyContainer>> graph = (Map<String, List<PropertyContainer>>) row.get("g"); assertEquals(asSet(pcs.get("a"),pcs.get("b")), asSet(graph.get("nodes").iterator())); assertEquals(asList(pcs.get("ab")), graph.get("relationships")); }; } }
assertEquals( asSet( dir1, dir2 ), asSet( fileSystem.listFiles( root ) ) ); assertEquals( asSet( subdir1, file1, file2 ), asSet( fileSystem.listFiles( dir1 ) ) ); assertEquals( asSet( file3 ), asSet( fileSystem.listFiles( dir2 ) ) ); assertEquals( asSet( file4 ), asSet( fileSystem.listFiles( subdir1 ) ) );
@Test public void shouldSerializePlanWithoutChildButAllKindsOfSupportedArguments() throws Exception args.put( "number", 1 ); args.put( "double", 2.3 ); args.put( "listOfInts", asList(1, 2, 3) ); args.put( "listOfListOfInts", asList( asList(1, 2, 3) ) ); Map<String, ?> rootMap = planRootMap( resultString ); assertEquals( asSet( "operatorType", "identifiers", "children", "string", "bool", "number", "double", "listOfInts", "listOfListOfInts" ), rootMap.keySet() ); assertEquals( operatorType, rootMap.get( "operatorType" ) ); assertEquals( args.get( "string" ), rootMap.get( "string" ) ); assertEquals( args.get( "bool" ), rootMap.get( "bool" ) ); assertEquals( args.get( "number" ), rootMap.get( "number" ) );
@Test public void shouldAddMissingLabels() throws Exception { // GIVEN String[] toAdd = new String[] {"Add1", "Add2"}; InputEntityVisitor node = additiveLabels( toAdd ).apply( entity ); // WHEN String[] nodeLabels = new String[] {"SomeOther"}; node( node, "source", 1, 0, "id", NO_PROPERTIES, null, nodeLabels, null ); // THEN assertEquals( asSet( ArrayUtil.union( toAdd, nodeLabels ) ), asSet( entity.labels() ) ); }
@Test public void relationshipTypesForDenseNodeWithPartiallyDeletedRelGroupChain() { testRelationshipTypesForDenseNode( this::noNodeChange, asSet( IN, OUT, LOOP ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, IN ), asSet( OUT, LOOP ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, OUT ), asSet( IN, LOOP ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, LOOP ), asSet( IN, OUT ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, IN, OUT ), asSet( LOOP ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, IN, LOOP ), asSet( OUT ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, OUT, LOOP ), asSet( IN ) ); testRelationshipTypesForDenseNode( nodeId -> markRelGroupNotInUse( nodeId, IN, OUT, LOOP ), emptySet() ); }
private void assertNextNode( InputIterator data, Group group, Object id, Object[] properties, Set<String> labels ) throws IOException { assertTrue( readNext( data ) ); assertEquals( group.id(), visitor.idGroup.id() ); assertEquals( id, visitor.id() ); assertArrayEquals( properties, visitor.properties() ); assertEquals( labels, asSet( visitor.labels() ) ); }
@Test public void shouldSerializePlanWithoutChildButWithIdentifiers() throws Exception { // given ByteArrayOutputStream output = new ByteArrayOutputStream(); ExecutionResultSerializer serializer = getSerializerWith( output, "http://base.uri/" ); String operatorType = "Ich habe einen Plan"; String id1 = "id1"; String id2 = "id2"; String id3 = "id3"; // This is the full set of types that we allow in plan arguments // when ExecutionPlanDescription planDescription = mockedPlanDescription( operatorType, asSet( id1, id2, id3 ), NO_ARGS, NO_PLANS ); serializer.statementResult( mockExecutionResult( planDescription ), false, ResultDataContent.rest ); serializer.finish(); String resultString = output.toString( UTF_8.name() ); // then assertIsPlanRoot( resultString ); Map<String,?> rootMap = planRootMap( resultString ); assertEquals( asSet( "operatorType", "identifiers", "children" ), rootMap.keySet() ); assertEquals( operatorType, rootMap.get( "operatorType" ) ); assertEquals( asList( id2, id1, id3 ), rootMap.get( "identifiers" ) ); }
@Test public void shouldListAllConstraintsForLabel() { // Given createUniquenessConstraint( label1, propertyKey ); createUniquenessConstraint( label2, propertyKey ); // When Set<ConstraintDescriptor> constraints = asSet( storageReader.constraintsGetForLabel( labelId( label1 ) ) ); // Then Set<?> expectedConstraints = asSet( uniqueConstraintDescriptor( label1, propertyKey ) ); assertEquals( expectedConstraints, constraints ); }
@Test public void shouldListActiveTransactions() throws Throwable { // Given KernelTransactions transactions = newTestKernelTransactions(); // When KernelTransaction first = getKernelTransaction( transactions ); KernelTransaction second = getKernelTransaction( transactions ); KernelTransaction third = getKernelTransaction( transactions ); first.close(); // Then assertThat( transactions.activeTransactions(), equalTo( asSet( newHandle( second ), newHandle( third ) ) ) ); }
assertEquals( asSet( labels ), names( node.getLabels() ) ); assertEquals( 0, expectedNodeNames.size() ); assertEquals( 0, expectedRelationships.size() );
@Test public void shouldSerializePlanWithChildren() throws Exception ExecutionPlanDescription left = mockedPlanDescription( "child", asSet( leftId ), MapUtil.map( "id", 1 ), NO_PLANS ); ExecutionPlanDescription right = mockedPlanDescription( "child", asSet( rightId ), MapUtil.map( "id", 2 ), NO_PLANS ); ExecutionPlanDescription parent = mockedPlanDescription( "parent", asSet( parentId ), MapUtil.map( "id", 0 ), asList( left, right ) ); JsonNode root = assertIsPlanRoot( result ); assertEquals( "parent", root.get( "operatorType" ).getTextValue() ); assertEquals( 0, root.get( "id" ).asLong() ); assertEquals( asSet( parentId ), identifiersOf( root ) ); childIds.add( child.get( "id" ).asInt() ); assertEquals( asSet( 1, 2 ), childIds ); assertEquals( asSet( asSet( leftId ), asSet( rightId ) ), identifiers );
@Test public void shouldAddAndGetByRuleId() { // GIVEN state.indexDoAdd( indexOn_1_1 ); // THEN assertEquals( asSet( indexOn_1_1 ), state.indexChanges().getAdded() ); }
@Test public void shouldAcceptRawAsciiCharacterCodeAsQuoteConfiguration() throws Exception { // GIVEN char weirdDelimiter = 1; // not '1', just the character represented with code 1, which seems to be SOH String name1 = weirdDelimiter + "Weird" + weirdDelimiter; String name2 = "Start " + weirdDelimiter + "middle thing" + weirdDelimiter + " end!"; File data = data( ":ID,name", "1," + name1, "2," + name2 ); // WHEN importTool( "--into", dbRule.getDatabaseDirAbsolutePath(), "--nodes", data.getAbsolutePath(), "--quote", String.valueOf( weirdDelimiter ) ); // THEN Set<String> names = asSet( "Weird", name2 ); GraphDatabaseService db = dbRule.getGraphDatabaseAPI(); try ( Transaction tx = db.beginTx() ) { for ( Node node : db.getAllNodes() ) { String name = (String) node.getProperty( "name" ); assertTrue( "Didn't expect node with name '" + name + "'", names.remove( name ) ); } assertTrue( names.isEmpty() ); tx.success(); } }
@Test public void indexReaderShouldSupportScan() throws Exception { // GIVEN updateAndCommit( asList( add( nodeId, value ), add( nodeId2, value2 ) ) ); IndexReader reader = accessor.newReader(); // WHEN LongIterator results = reader.query( IndexQuery.exists( PROP_ID ) ); // THEN assertEquals( asSet( nodeId, nodeId2 ), PrimitiveLongCollections.toSet( results ) ); assertEquals( asSet( nodeId ), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value ) ) ) ); reader.close(); }
@Test public void shouldCreateUnionOfIndexLimitations() { UnionIndexCapability union; // given union = unionOfIndexLimitations( IndexCapability.LIMITIATION_NONE, IndexCapability.LIMITIATION_NONE ); // then assertEquals( Collections.emptySet(), asSet( union.limitations() ) ); // given union = unionOfIndexLimitations( IndexCapability.LIMITIATION_NONE, array( IndexLimitation.SLOW_CONTAINS ) ); // then assertEquals( asSet( IndexLimitation.SLOW_CONTAINS ), asSet( union.limitations() ) ); // given union = unionOfIndexLimitations( array( IndexLimitation.SLOW_CONTAINS ), array( IndexLimitation.SLOW_CONTAINS ) ); // then assertEquals( asSet( IndexLimitation.SLOW_CONTAINS ), asSet( union.limitations() ) ); }
@Test public void applicationOfIndexUpdatesShouldThrowIfServiceIsShutdown() throws IOException, IndexEntryConflictException { // Given IndexingService indexingService = newIndexingServiceWithMockedDependencies( populator, accessor, withData() ); life.start(); life.shutdown(); try { // When indexingService.apply( updates( asSet( add( 1, "foo" ) ) ) ); fail( "Should have thrown " + IllegalStateException.class.getSimpleName() ); } catch ( IllegalStateException e ) { // Then assertThat( e.getMessage(), startsWith( "Can't apply index updates" ) ); } }
@Test public void indexReaderShouldHonorRepeatableReads() throws Exception { // GIVEN updateAndCommit( asList( add( nodeId, value ) ) ); IndexReader reader = accessor.newReader(); // WHEN updateAndCommit( asList( remove( nodeId, value ) ) ); // THEN assertEquals( asSet( nodeId ), PrimitiveLongCollections.toSet( reader.query( exact( PROP_ID, value ) ) ) ); reader.close(); }