-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing method in BMS service for equals block #152
Open
Lexsus
wants to merge
2
commits into
StnetixDevTeam:master
Choose a base branch
from
Lexsus:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
|
||
import com.stnetix.ariaddna.blockmanipulation.exception.BlockDoesNotExistException; | ||
import com.stnetix.ariaddna.blockmanipulation.exception.MetafileIsFolderException; | ||
import com.stnetix.ariaddna.vufs.bo.Block; | ||
import com.stnetix.ariaddna.vufs.bo.Metafile; | ||
import com.stnetix.ariaddna.vufs.bo.Metatable; | ||
|
||
public interface IBlockManipulationService { | ||
|
||
|
@@ -35,11 +37,26 @@ String getNextBlockUuid(Metafile metafile) throws MetafileIsFolderException, | |
* Method return Block uuid by number from Metafile. If metafile is folder, method | ||
* throws {@link MetafileIsFolderException}. | ||
* if Metafile doesn`t exist block with external number, throws {@link BlockDoesNotExistException}. | ||
* @param metafile Metafil object. | ||
* @param metafile Metafile object. | ||
* @param blockNumber number of requested block. | ||
* @return uuid of block with requsted number. | ||
* @throws {@link BlockDoesNotExistException}, {@link MetafileIsFolderException} | ||
* */ | ||
String getBlockUuidByNumber(Metafile metafile, int blockNumber) | ||
throws MetafileIsFolderException, BlockDoesNotExistException; | ||
|
||
/** | ||
* Method checks the presence of a block in Metatable | ||
* @param block Block object | ||
* @param metatable Metatable object | ||
* @return return true if Metatable contains block and otherwise return false | ||
*/ | ||
boolean checkBlock(Block block,Metatable metatable); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change name of method to "isExistOnVufs" |
||
|
||
/** | ||
* Methot remove block from cache | ||
* @param block Block object | ||
* @param metatable Metatable object | ||
*/ | ||
void removeBlockFromCache(Block block,Metatable metatable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,18 @@ | |
package com.stnetix.ariaddna.blockmanipulation.service; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Random; | ||
import java.util.UUID; | ||
|
||
import com.stnetix.ariaddna.commonutils.datetime.DateTime; | ||
import com.stnetix.ariaddna.commonutils.dto.vufs.MetatableType; | ||
import com.stnetix.ariaddna.vufs.bo.Block; | ||
import com.stnetix.ariaddna.vufs.bo.Metatable; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
@@ -81,6 +88,51 @@ public void getNextBlockUuid() throws BlockDoesNotExistException, MetafileIsFold | |
blockManipulationService.getNextBlockUuid(metafile); | ||
} | ||
|
||
@Test | ||
public void CheckBlock() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change name of method to "isExistOnVufs" |
||
int blockSize = 1024; | ||
String version = "1"; | ||
byte[] data = new byte[blockSize]; | ||
DateTime date = new DateTime(); | ||
|
||
Map<String, String> properties = new HashMap<>(); | ||
properties.put("typeOnFs", FileType.FILE_BIN.toString()); | ||
metafile.setProperties(properties); | ||
|
||
Random random = new Random(); | ||
random.nextBytes(data); | ||
Block block1 = new Block(version, 0L, metafile.getFileUuid(), data, | ||
date.getTimeInMillisec(), | ||
(long) blockSize); | ||
random.nextBytes(data); | ||
Block block2 = new Block(version, 1L, metafile.getFileUuid(), data, | ||
date.getTimeInMillisec(), | ||
(long) blockSize); | ||
random.nextBytes(data); | ||
Block block3 = new Block(version, 1L, metafile.getFileUuid(), data, | ||
date.getTimeInMillisec(), | ||
(long) blockSize); | ||
random.nextBytes(data); | ||
Block block4 = new Block(version, 1L, metafile.getFileUuid(), data, | ||
date.getTimeInMillisec(), | ||
(long) blockSize); | ||
metafile.addBlockUuid(block1.getBlockUuid()); | ||
metafile.addBlockUuid(block2.getBlockUuid()); | ||
metafile.addBlockUuid(block3.getBlockUuid()); | ||
|
||
Metatable metatable = new Metatable(MetatableType.MASTER, UUID.randomUUID().toString(), | ||
UUID.randomUUID().toString()); | ||
metatable.addMetafile(metafile); | ||
assertTrue(blockManipulationService.checkBlock(block3, metatable)); | ||
assertFalse(blockManipulationService.checkBlock(block4, metatable)); | ||
assertTrue(blockManipulationService.checkBlock(block3, metatable)); | ||
|
||
//remove block | ||
metafile.removeBlockUuid(block3.getBlockUuid()); | ||
blockManipulationService.removeBlockFromCache(block3, metatable); | ||
assertFalse(blockManipulationService.checkBlock(block3, metatable)); | ||
} | ||
|
||
@Test(expected = MetafileIsFolderException.class) | ||
public void getNextBlockUuidByFolder() | ||
throws BlockDoesNotExistException, MetafileIsFolderException { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change name of method to "isExistOnVufs"