Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

RostyslavKuzmych
Copy link

No description provided.

Copy link

@kshuryhin kshuryhin left a 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;

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?

Comment on lines 35 to 37
private ReaderService readerService;
private FruitService fruitService;
private TypeActivityStrategy typeActivityStrategy;

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

Copy link

@dima-semeniuk dima-semeniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

Comment on lines 19 to 22
@BeforeEach
void beforeEach() {

}

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

Comment on lines 19 to 22
@BeforeEach
void beforeEach() {

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is redundant too

Copy link

@bhdnchui bhdnchui left a 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() {

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.

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

Comment on lines 55 to 56
assertThrows(RuntimeException.class,
() -> fruitTransactionDao.addToStorage(null));

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,

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()));

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() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find a better name.

Comment on lines 16 to 19
@BeforeEach
void beforeEach() {

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@BeforeEach
void beforeEach() {
}

private static final String APPLE = "apple";

@BeforeEach
void beforeEach() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Comment on lines 42 to 46
purchaseActivityHandler
.setAmountOfFruit(FruitTransaction.of(Operation.PURCHASE, BANANA, 10));

purchaseActivityHandler
.setAmountOfFruit(FruitTransaction.of(Operation.PURCHASE, APPLE, 40));

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.

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,

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";

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.

Copy link

@d1sam d1sam left a 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.

Comment on lines +31 to +44
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);
Copy link

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants