VufsServiceImpl implements IVufsService { @Override public void setAllocationForBlockByUuid(String blockUuid, Set<String> allocationSet) throws BlockNotExistInMetatableException { boolean isAdded = false; for (Metafile metafile : currentMetatable.getMetafileSet()) { if (metafile.getBlockUuidList().contains(blockUuid)) { isAdded = true; for (String cloud : allocationSet) { metafile.addBlockAllocation(blockUuid, cloud); } break; } } if (!isAdded) { throw new BlockNotExistInMetatableException(MessageFormat.format( "Block with uuid: {0}, does not exist in currentMetatable with uuid: {1}, with type: {2}", blockUuid, currentMetatable.getUuid(), currentMetatable.getType())); } } @Autowired  VufsServiceImpl(IProfile profile,
            MetatableTransformer metatableTransformer,
            IMetatableService persistingService); @Override Metafile createEmptyMetafile(); @Override Metafile getMetafileByUuid(String fileUuid); @Override Metafile addBlockByUuidToMetafile(String blockUuid, Metafile metafile); @Override Metafile removeBlockByUuidFromMetafile(String blockUuid, Metafile metafile); @Override boolean addMetafileToMetatable(Metafile metafile); @Override boolean removeMetafileFromMetatable(Metafile metafile); @Override Set<String> getAllocationByBlockUuid(String blockUuid); @Override void setAllocationForBlockByUuid(String blockUuid, Set<String> allocationSet); @Override boolean addMetafileAsChildToParent(Metafile childMetafile,
            String parentMetafileUuid); @Override boolean removeMetafileFromParent(String childMetafileUuid,
            String parentMetafileUuid); @Override AllocationStrategy getAllocationStrategyByMetafileUuid(String metafileUuid); @Override void setAllocationStrategyByMetafileUuid(String metafileUuid,
            AllocationStrategy allocationStrategy); @PreDestroy void persistChanges();  }
@Test public void setAllocationForBlockByUuid() throws BlockNotExistInMetatableException { Metafile newMetafile = vufsService.createEmptyMetafile(); newMetafile.setAllocationStrategy(AllocationStrategy.HA); vufsService.addMetafileToMetatable(newMetafile); String newBlockUuid = UUID.randomUUID().toString(); vufsService.addBlockByUuidToMetafile(newBlockUuid, newMetafile); Set<String> allocationSet = new HashSet<>(5); for (int i = 0; i < 5; i++) { allocationSet.add(UUID.randomUUID().toString()); } vufsService.setAllocationForBlockByUuid(newBlockUuid, allocationSet); Set<String> resultAllocationSet = vufsService.getAllocationByBlockUuid(newBlockUuid); assertFalse(resultAllocationSet.isEmpty()); assertEquals(resultAllocationSet.size(), 5); }