From 489f18c1fc6b9bfa6092dee0824d041cc37de5d2 Mon Sep 17 00:00:00 2001 From: mikhail lyubimtsev Date: Mon, 6 Oct 2025 00:54:53 +0300 Subject: [PATCH] commit-1 --- pom.xml | 142 +++++++++++++++++++++++- src/test/java/praktikum/BurgerTest.java | 74 ++++++++++++ target/site/jacoco/index.html | 1 + 3 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 src/test/java/praktikum/BurgerTest.java create mode 100644 target/site/jacoco/index.html diff --git a/pom.xml b/pom.xml index 184bdae89..66daea0d3 100644 --- a/pom.xml +++ b/pom.xml @@ -1,16 +1,152 @@ + + + + + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + + http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.example + praktikum + 1.0-SNAPSHOT + + - 11 - 11 + + 17 + + 17 + + + + + + + + + + junit + + junit + + 4.13.2 + + test + + + + + + + + + + org.mockito + + mockito-core + + 5.6.0 + + test + + + + + + + + + + org.hamcrest + + hamcrest + + 2.2 + + test + + + + + + net.bytebuddy + + byte-buddy + + 1.15.3 + + test + + + + + + junit + + junit + + 4.13.1 + + test + + + + + + + + + + + + + + + + org.apache.maven.plugins + + maven-surefire-plugin + + 3.0.0-M8 + + + + org.jacoco + jacoco-maven-plugin + 0.8.11 + + + + prepare-agent + + + + report + test + + report + + + + + + + + + + + diff --git a/src/test/java/praktikum/BurgerTest.java b/src/test/java/praktikum/BurgerTest.java new file mode 100644 index 000000000..9a7c47f09 --- /dev/null +++ b/src/test/java/praktikum/BurgerTest.java @@ -0,0 +1,74 @@ +package praktikum; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class BurgerTest { + + private Burger burger; + private Bun bun; + private Ingredient sauce; + private Ingredient filling1; + private Ingredient filling2; + + @Before + public void setUp() { + burger = new Burger(); + + bun = new Bun("black bun", 100f); + burger.setBuns(bun); + + sauce = new Ingredient(IngredientType.SAUCE, "sour cream", 200f); + filling1 = new Ingredient(IngredientType.FILLING, "cutlet", 100f); + filling2 = new Ingredient(IngredientType.FILLING, "dinosaur", 200f); + + burger.addIngredient(sauce); + burger.addIngredient(filling1); + burger.addIngredient(filling2); + } + + @Test + public void testGetReceipt() { + String receipt = burger.getReceipt(); + + assertTrue(receipt.contains("(==== black bun ====)")); + assertTrue(receipt.contains("= sauce sour cream =")); + assertTrue(receipt.contains("= filling cutlet =")); + assertTrue(receipt.contains("= filling dinosaur =")); + assertTrue(receipt.contains("Price: 700")); + } + + @Test + public void testAddIngredient() { + Ingredient cheese = new Ingredient(IngredientType.FILLING, "cheese", 50f); + burger.addIngredient(cheese); + + assertEquals(4, burger.ingredients.size()); + assertTrue(burger.ingredients.contains(cheese)); + } + + @Test + public void testRemoveIngredient() { + burger.removeIngredient(1); // удаляем "cutlet" + + assertEquals(2, burger.ingredients.size()); + assertFalse(burger.ingredients.contains(filling1)); + } + + @Test + public void testMoveIngredient() { + burger.moveIngredient(0, 2); // sauce переместится в конец + + assertEquals(filling1, burger.ingredients.get(0)); + assertEquals(filling2, burger.ingredients.get(1)); + assertEquals(sauce, burger.ingredients.get(2)); + } + + @Test + public void testGetPrice() { + float price = burger.getPrice(); + assertEquals(700f, price, 0.001f); + } +} diff --git a/target/site/jacoco/index.html b/target/site/jacoco/index.html new file mode 100644 index 000000000..8b0442477 --- /dev/null +++ b/target/site/jacoco/index.html @@ -0,0 +1 @@ +praktikum

praktikum

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total165 of 34952 %0 of 4100 %522296952026
praktikum16518452 %4100 %522296952026
\ No newline at end of file