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

add tests to fruitshop solution #787

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DenisGorda
Copy link

No description provided.

Copy link

@validatorr validatorr left a comment

Choose a reason for hiding this comment

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

LGTM! Actually, I don't know what to fix here, structure looks good.

void addProductToEmptyStorage_Ok() {
StorageDao storageDao = new StorageDaoImpl();
storageDao.add(banana, quantity);
Integer expected = 50;

Choose a reason for hiding this comment

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

maybe you should use constants for all the numbers, so code could look cleaner

Choose a reason for hiding this comment

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

you don't need to use constants in tests

static void setUp() {
apple = new Fruit("apple");
supplyOperationHandler = new SupplyOperationHandler();
Storage.storage.clear();

Choose a reason for hiding this comment

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

Should you use Storage.storage.clear() here if you use it in @AfterEach?

Choose a reason for hiding this comment

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

agree with @validatorr

Copy link

@Andriy-dz Andriy-dz left a comment

Choose a reason for hiding this comment

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

pay attention to your method names, they don't match the pattern

Comment on lines +14 to +16
private final Fruit banana = new Fruit("banana");
private final Fruit apple = new Fruit("apple");
private final int quantity = 50;

Choose a reason for hiding this comment

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

why u need this field?

void addProductToEmptyStorage_Ok() {
StorageDao storageDao = new StorageDaoImpl();
storageDao.add(banana, quantity);
Integer expected = 50;

Choose a reason for hiding this comment

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

you don't need to use constants in tests


@Test
void addProductToEmptyStorage_Ok() {
StorageDao storageDao = new StorageDaoImpl();

Choose a reason for hiding this comment

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

make it class field and use in all test methods

}

@Test
void subtractProduct_Ok() {

Choose a reason for hiding this comment

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

wrong name. which of the methods are you testing. Same in another tests

Comment on lines +12 to +14
private static Fruit apple;
private static OperationHandler balanceOperationHandler;
private static FruitTransaction fruitTransaction;

Choose a reason for hiding this comment

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

Suggested change
private static Fruit apple;
private static OperationHandler balanceOperationHandler;
private static FruitTransaction fruitTransaction;
private static OperationHandler balanceOperationHandler;

u dont need this as class field

Choose a reason for hiding this comment

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

same in another classes

@BeforeAll
static void setUp() {
apple = new Fruit("apple");
balanceOperationHandler = new BalanceOperationHandler();

Choose a reason for hiding this comment

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

StorageDao in your implementations must be initialized in the constructor. Same everywhere

static void setUp() {
apple = new Fruit("apple");
supplyOperationHandler = new SupplyOperationHandler();
Storage.storage.clear();

Choose a reason for hiding this comment

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

agree with @validatorr

final int initialBananaBalance = Storage.storage.get(banana);
final int initialAppleBalance = Storage.storage.get(apple);
int quantity = 25;
FruitTransaction transaction1 = new FruitTransaction();

Choose a reason for hiding this comment

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

StorageDao in your implementations must be initialized in the constructor. Same in another cases

transactions.add(transaction1);
transactions.add(transaction2);

operationProcessorService.process(transactions, operationStrategy);

Choose a reason for hiding this comment

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

OperationStrategy must by class field. U dont need set it as parameter

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.

3 participants