DiskStoreRealizer implements ConfigurationRealizer<DiskStore, DiskStoreInfo> { @Override public RealizationResult create(DiskStore config, InternalCache cache) throws Exception { DiskStoreAttributes diskStoreAttributes = new DiskStoreAttributes(); if (config.isAllowForceCompaction() != null) { diskStoreAttributes.allowForceCompaction = config.isAllowForceCompaction(); } if (config.isAutoCompact() != null) { diskStoreAttributes.autoCompact = config.isAutoCompact(); } if (config.getCompactionThreshold() != null) { diskStoreAttributes.compactionThreshold = config.getCompactionThreshold(); } if (config.getDiskUsageCriticalPercentage() != null) { diskStoreAttributes.setDiskUsageCriticalPercentage(config.getDiskUsageCriticalPercentage()); } if (config.getDiskUsageWarningPercentage() != null) { diskStoreAttributes.setDiskUsageWarningPercentage(config.getDiskUsageWarningPercentage()); } if (config.getMaxOplogSizeInBytes() != null) { diskStoreAttributes.maxOplogSizeInBytes = config.getMaxOplogSizeInBytes(); } if (config.getQueueSize() != null) { diskStoreAttributes.queueSize = config.getQueueSize(); } if (config.getTimeInterval() != null) { diskStoreAttributes.timeInterval = config.getTimeInterval(); } if (config.getWriteBufferSize() != null) { diskStoreAttributes.writeBufferSize = config.getWriteBufferSize(); } List<File> fileList = config.getDirectories().stream().map(diskDir -> new File(diskDir.getName())) .collect(Collectors.toList()); diskStoreAttributes.diskDirs = fileList.toArray(diskStoreAttributes.diskDirs); diskStoreAttributes.diskDirSizes = config.getDirectories().stream().mapToInt(diskDir -> { if (diskDir.getDirSize() != null) { return diskDir.getDirSize(); } else { return Integer.MAX_VALUE; } }).toArray(); DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(diskStoreAttributes); diskStoreFactory.create(config.getName()); return new RealizationResult() .setMessage("DiskStore " + config.getName() + " created successfully."); }  @Override RealizationResult create(DiskStore config, InternalCache cache); @Override boolean exists(DiskStore config, InternalCache cache); @Override DiskStoreInfo get(DiskStore config, InternalCache cache); @Override RealizationResult update(DiskStore config, InternalCache cache); @Override RealizationResult delete(DiskStore config, InternalCache cache); @Override boolean isReadyOnly();  }
@Test public void creatingDiskStoreWithNameShouldSucceed() throws Exception { DiskStore config = new DiskStore(); String name = "diskStoreName"; config.setName(name); config.setDirectories(new ArrayList()); RealizationResult result = diskStoreRealizer.create(config, cache); verify(diskStoreFactory, times(1)).create(name); assertThat(result.getMessage()) .isEqualTo("DiskStore " + config.getName() + " created successfully."); assertThat(result.isSuccess()).isTrue(); }