Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company.oop.cosmetics.tests.models;
- import com.company.oop.cosmetics.exceptions.InvalidUserInputException;
- import com.company.oop.cosmetics.models.CategoryImpl;
- import com.company.oop.cosmetics.models.GenderType;
- import com.company.oop.cosmetics.models.ProductImpl;
- import com.company.oop.cosmetics.models.contracts.Product;
- import org.junit.jupiter.api.Assertions;
- import org.junit.jupiter.api.Test;
- import java.util.ArrayList;
- import java.util.List;
- public class CategoryImplTests {
- // @Test
- // public void constructor_Should_InitializeName_When_ArgumentsAreValid() {
- // // Arange
- // String name = "Name";
- //
- // // Act
- // CategoryImpl category = new CategoryImpl(name);
- //
- // // Assert
- // Assertions.assertNotNull(category);
- //
- // }
- //
- // @Test
- // public void constructor_Should_InitializeProducts_When_ArgumentsAreValid() {
- //
- // // Arange
- // String name = "Name";
- //
- // // Act
- // CategoryImpl category = new CategoryImpl(name);
- //
- // // Assert
- // Assertions.assertEquals(name, category.getName(), "Not correct!");
- //
- // }
- //
- // @Test
- // public void constructor_Should_ThrowException_When_NameIsShorterThanExpected() {
- // // Arange
- // String name = "Na";
- //
- // // Act
- /// / CategoryImpl category = new CategoryImpl(name);
- //
- // // Assert
- // Assertions.assertThrows(InvalidUserInputException.class, () -> {
- // new CategoryImpl(name);
- // });
- //
- // }
- //
- // @Test
- // public void addProduct_Should_AddProductToList() {
- //
- // //Arrange
- // var category = new CategoryImpl("TestCateg");
- // var product = new ProductImpl("TestProduct", "TestBrand", 10.0, GenderType.MEN);
- //
- // //Act
- // category.addProduct(product);
- //
- // //Assert
- // Assertions.assertEquals(1, category.getProducts().size());
- //
- //
- // }
- @Test
- public void removeProduct_Should_RemoveProductFromList_When_ProductExist() {
- //Arrange
- var category = new CategoryImpl("TestCateg");
- var product = new ProductImpl("TestPr", "TestBrand", 10.0, GenderType.MEN);
- var product2 = new ProductImpl("TestPr", "TestBrand", 10.0, GenderType.MEN);
- //Act
- category.addProduct(product);
- category.addProduct(product2);
- category.removeProduct(product2);
- //Assert
- Assertions.assertEquals(1, category.getProducts().size());
- }
- @Test
- public void removeProduct_should_notRemoveProductFromList_when_productNotExist() {
- //Arrange
- var category = new CategoryImpl("TestCateg");
- var product = new ProductImpl("TestPr", "TestBrand", 10.0, GenderType.MEN);
- var product2 = new ProductImpl("TestPr", "TestBrand", 10.0, GenderType.MEN);
- var product3 = new ProductImpl("TestPr", "TestBrand", 10.0, GenderType.MEN);
- var product4 = new ProductImpl("TestPr", "TestBrand", 10.0, GenderType.MEN);
- //Act
- category.addProduct(product);
- category.addProduct(product2);
- // category.removeProduct(product);
- category.removeProduct(product3);
- category.addProduct(product4);
- //Assert
- // Assertions.assertTrue(category.getProducts().contains(product));
- // Assertions.assertFalse(category.getProducts().contains(product));
- Assertions.assertEquals(3, category.getProducts().size());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement