-
Notifications
You must be signed in to change notification settings - Fork 1k
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
implemented the requirement of the task #816
base: main
Are you sure you want to change the base?
Conversation
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.
Good job, one more tip - try to add <_state_>
part to your test names. It will make tests more readable generally
private static final String BANANA = "banana"; | ||
private static final String APPLE = "apple"; | ||
private BalanceActivityHandler balanceActivityHandler; | ||
private FruitTransactionDao fruitTransactionDao; |
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.
Do we need this variable on the class level?
private ReaderService readerService; | ||
private FruitService fruitService; | ||
private TypeActivityStrategy typeActivityStrategy; |
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.
Some of these variables are also not needed on the class level I guess
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.
Great job!
@BeforeEach | ||
void beforeEach() { | ||
|
||
} |
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.
I guess this is redundant
@BeforeEach | ||
void beforeEach() { | ||
|
||
} |
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.
It is redundant too
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.
Good job, but a few comments need to be processed.
} | ||
|
||
@Test | ||
void get_FromStorage_isOk() { |
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.
First letter after _ should be lower case.
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.
Here you test get and store in the same test.
Separate to two tests:
- store with Storage and get with fruitTransactionDao
- store with fruitTransactionDao and get with Storage
assertThrows(RuntimeException.class, | ||
() -> fruitTransactionDao.addToStorage(null)); |
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.
I think it is a bad opportunity to get RuntimeException
void subtract_IncorrectQuantity_isNotOk() { | ||
FruitTransaction fruitTransaction | ||
= FruitTransaction.of(Operation.RETURN, BANANA, 20); | ||
assertThrows(RuntimeException.class, |
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.
Let's not throw RuntimeException.
Also you can add check for a message.
activityHandlerMap = new HashMap<>(); | ||
|
||
activityHandlerMap.put(Operation.BALANCE, | ||
new BalanceActivityHandler(new FruitTransactionDaoImpl())); |
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.
You can make new FruitTransactionDaoImpl() one time.
} | ||
|
||
@Test | ||
void write_Report_isOk() { |
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.
Find a better name.
@BeforeEach | ||
void beforeEach() { | ||
|
||
} |
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.
@BeforeEach | |
void beforeEach() { | |
} |
private static final String APPLE = "apple"; | ||
|
||
@BeforeEach | ||
void beforeEach() { |
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.
Remove
purchaseActivityHandler | ||
.setAmountOfFruit(FruitTransaction.of(Operation.PURCHASE, BANANA, 10)); | ||
|
||
purchaseActivityHandler | ||
.setAmountOfFruit(FruitTransaction.of(Operation.PURCHASE, APPLE, 40)); |
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.
Let's make a two separate tests here.
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.
It is actual for all ActivityHandlersImpl
|
||
@Test | ||
void get_HandlerFromNull_isNotOk() { | ||
assertThrows(NullPointerException.class, |
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.
It is not ok. You should handle such case in code.
|
||
class WriterServiceTest { | ||
private static final String EXIST_FILE = "newFile.CSV"; | ||
private static final String NON_EXIST_FILE = "file1.CSV"; |
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.
You add such file to you PR.
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.
Well done, but please better choose variable names.
FruitTransaction fruitTransaction | ||
= FruitTransaction.of(Operation.BALANCE, APPLE, 100); | ||
|
||
FruitTransaction fruitTransaction1 | ||
= FruitTransaction.of(Operation.RETURN, APPLE, 50); | ||
|
||
FruitTransaction fruitTransaction2 | ||
= FruitTransaction.of(Operation.BALANCE, BANANA, 100); | ||
|
||
FruitTransaction fruitTransaction3 | ||
= FruitTransaction.of(Operation.PURCHASE, BANANA, 20); | ||
|
||
FruitTransaction fruitTransaction4 | ||
= FruitTransaction.of(Operation.SUPPLY, APPLE, 50); |
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 choose better names for variables. Without ending 1,2,3..
No description provided.