@Test void shouldMakeFromCanonical() throws IOException, CommandFailed, IncorrectUsage, IncorrectFormat { Path dataDir = testDirectory.directory( "some-other-path" ).toPath(); Path databaseDir = dataDir.resolve( "databases/foo.db" ); Files.createDirectories( databaseDir ); Files.write( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ), singletonList( formatProperty( data_directory, dataDir ) ) ); new LoadCommand( homeDir, configDir, loader ) .execute( ArrayUtil.concat( new String[]{"--database=foo.db", "--from=foo.dump"} ) ); verify( loader ).load( eq( Paths.get( new File( "foo.dump" ).getCanonicalPath() ) ), any(), any() ); }
@Test void shouldConcatArrays() { // GIVEN Integer[] initial = new Integer[] {0, 1, 2}; // WHEN Integer[] all = ArrayUtil.concat( initial, 3, 4, 5 ); // THEN assertArrayEquals( new Integer[] {0, 1, 2, 3, 4, 5}, all ); }
@Test void shouldConcatOneAndMany() { // WHEN Integer[] result = ArrayUtil.concat( 0, 1, 2, 3, 4 ); // THEN for ( int i = 0; i < 5; i++ ) { assertEquals( (Integer)i, result[i] ); } }
private void execute( String database, String... otherArgs ) throws IncorrectUsage, CommandFailed { new LoadCommand( homeDir, configDir, loader ) .execute( ArrayUtil.concat( new String[]{"--database=" + database, "--from=" + archive}, otherArgs ) ); }
@Test void shouldFindIndexOf() { // GIVEN Integer[] numbers = ArrayUtil.concat( 0, 1, 2, 3, 4, 5 ); // WHEN/THEN for ( int i = 0; i < 6; i++ ) { assertEquals( i, ArrayUtil.indexOf( numbers, i ) ); } }
public void migrate( DatabaseLayout fromDirectoryStructure, RecordFormats fromFormat, DatabaseLayout toDirectoryStructure, RecordFormats toFormat, ProgressReporter progressReporter, StoreType[] types, StoreType... additionalTypesToOpen ) { StoreType[] storesToOpen = ArrayUtil.concat( types, additionalTypesToOpen ); progressReporter.start( storesToOpen.length ); try ( NeoStores fromStores = new StoreFactory( fromDirectoryStructure, config, new DefaultIdGeneratorFactory( fs ), pageCache, fs, fromFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, storesToOpen ); NeoStores toStores = new StoreFactory( toDirectoryStructure, withPersistedStoreHeadersAsConfigFrom( fromStores, storesToOpen ), new DefaultIdGeneratorFactory( fs ), pageCache, fs, toFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, storesToOpen ) ) { for ( StoreType type : types ) { // This condition will exclude counts store first and foremost. if ( type.isRecordStore() ) { migrate( fromStores.getRecordStore( type ), toStores.getRecordStore( type ) ); progressReporter.progress( 1 ); } } } }
@Test void shouldRemoveItems() { // GIVEN Integer[] numbers = ArrayUtil.concat( 0, 1, 2, 3, 4, 5 ); // WHEN Integer[] trimmed = ArrayUtil.without( numbers, 2 ); trimmed = ArrayUtil.without( trimmed, 5 ); trimmed = ArrayUtil.without( trimmed, 0 ); // THEN assertEquals( 3, trimmed.length ); assertFalse( ArrayUtil.contains( trimmed, 0 ) ); assertTrue( ArrayUtil.contains( trimmed, 1 ) ); assertFalse( ArrayUtil.contains( trimmed, 2 ) ); assertTrue( ArrayUtil.contains( trimmed, 3 ) ); assertTrue( ArrayUtil.contains( trimmed, 4 ) ); assertFalse( ArrayUtil.contains( trimmed, 5 ) ); }
Provider[] providersIncludingSubject = concat( providers, DEFAULT_PROVIDER ); int expectedNumberOfIndexes = providers.length * 2; try
public void migrate( DatabaseLayout fromDirectoryStructure, RecordFormats fromFormat, DatabaseLayout toDirectoryStructure, RecordFormats toFormat, ProgressReporter progressReporter, StoreType[] types, StoreType... additionalTypesToOpen ) { StoreType[] storesToOpen = ArrayUtil.concat( types, additionalTypesToOpen ); progressReporter.start( storesToOpen.length ); try ( NeoStores fromStores = new StoreFactory( fromDirectoryStructure, config, new DefaultIdGeneratorFactory( fs ), pageCache, fs, fromFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, storesToOpen ); NeoStores toStores = new StoreFactory( toDirectoryStructure, withPersistedStoreHeadersAsConfigFrom( fromStores, storesToOpen ), new DefaultIdGeneratorFactory( fs ), pageCache, fs, toFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, storesToOpen ) ) { for ( StoreType type : types ) { // This condition will exclude counts store first and foremost. if ( type.isRecordStore() ) { migrate( fromStores.getRecordStore( type ), toStores.getRecordStore( type ) ); progressReporter.progress( 1 ); } } } }