### Question:
DatasetBuilder { public static BuildFromFile file() { return new DatasetBuilder().new BuildFromFile(); } private  DatasetBuilder(); static BuildFromFile file(); static BuildFromBuffer buffer(); static final int STRINGS_CACHE_SIZE; static final int NODES_CACHE_SIZE; static final int VALUES_CACHE_SIZE; static final int PROFILES_CACHE_SIZE; static final int SIGNATURES_CACHE_SIZE; }### Answer:
@Test public void testDefaultIsNoCaches () throws IOException { IndirectDataset dataset = DatasetBuilder.file() .build(Filename.LITE_PATTERN_V32); assertEquals(null, dataset.getCache(StringsCache)); assertEquals(null, dataset.getCache(SignaturesCache)); assertEquals(null, dataset.getCache(NodesCache)); assertEquals(null, dataset.getCache(ValuesCache)); assertEquals(null, dataset.getCache(ProfilesCache)); }
@Test public void testAddDefaultCaches () throws IOException { IndirectDataset dataset = DatasetBuilder.file() .configureDefaultCaches() .build(Filename.LITE_PATTERN_V32); assertEquals(LruCache.class, dataset.getCache(StringsCache).getClass()); assertEquals(LruCache.class, dataset.getCache(SignaturesCache).getClass()); assertEquals(LruCache.class, dataset.getCache(NodesCache).getClass()); assertEquals(LruCache.class, dataset.getCache(ValuesCache).getClass()); assertEquals(LruCache.class, dataset.getCache(ProfilesCache).getClass()); }
@Test public void testCreate32FromBuilder () throws Exception { File temp = File.createTempFile("Test",".dat"); File source = new File(Filename.LITE_PATTERN_V32); Files.copy(source, temp); Dataset dataset = DatasetBuilder.file() .lastModified(new Date()) .build(temp.getPath()); ViableProvider.ensureViableProvider(new Provider(dataset)); dataset.close(); assertTrue(temp.exists()); dataset = DatasetBuilder.file() .setTempFile() .lastModified(new Date()) .build(temp.getPath()); ViableProvider.ensureViableProvider(new Provider(dataset)); dataset.close(); assertFalse(temp.exists()); }
@Test(expected = NoSuchElementException.class) public void testIterator () throws Exception { IndirectDataset indirectDataset = DatasetBuilder.file() .lastModified(new Date()) .build(Filename.LITE_PATTERN_V32); Iterator it = indirectDataset.profiles.iterator(); while (it.hasNext()) { it.next(); } it.next(); }
@Test public void testMemoryStreamDatasetConsistentNoCache () throws IOException { IndirectDataset indirectDataset = DatasetBuilder.file() .lastModified(new Date()) .build(Filename.LITE_PATTERN_V32); Dataset memoryDataset = MemoryFactory.create(Filename.LITE_PATTERN_V32); compareDatasets(indirectDataset, memoryDataset); }
@Test public void testMemoryStreamDatasetConsistentPartialLruCache () throws IOException { IndirectDataset indirectDataset = DatasetBuilder.file() .configureCache(NodesCache, new CacheOptions(20, LruCache.builder())) .configureCache(ValuesCache, new CacheOptions(100, LruCache.builder())) .configureCache(StringsCache, new CacheOptions(100, LruCache.builder())) .build(Filename.LITE_PATTERN_V32); Dataset memoryDataset = MemoryFactory.create(Filename.LITE_PATTERN_V32); compareDatasets(indirectDataset, memoryDataset); }