Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 139 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>



<project xmlns="http://maven.apache.org/POM/4.0.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>



<groupId>org.example</groupId>

<artifactId>praktikum</artifactId>

<version>1.0-SNAPSHOT</version>



<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<maven.compiler.source>17</maven.compiler.source>

<maven.compiler.target>17</maven.compiler.target>

</properties>



<dependencies>

<!-- JUnit 4 -->

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.13.2</version>

<scope>test</scope>

</dependency>



<!-- Mockito -->

<dependency>

<groupId>org.mockito</groupId>

<artifactId>mockito-core</artifactId>

<version>5.6.0</version>

<scope>test</scope>

</dependency>



<!-- Optional: Hamcrest для assertThat -->

<dependency>

<groupId>org.hamcrest</groupId>

<artifactId>hamcrest</artifactId>

<version>2.2</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>net.bytebuddy</groupId>

<artifactId>byte-buddy</artifactId>

<version>1.15.3</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.13.1</version>

<scope>test</scope>

</dependency>

</dependencies>



<build>

<plugins>

<!-- Плагин для Maven Surefire (запуск тестов) -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-surefire-plugin</artifactId>

<version>3.0.0-M8</version>

</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

</build>

</project>


74 changes: 74 additions & 0 deletions src/test/java/praktikum/BurgerTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions target/site/jacoco/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="ru"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="jacoco-resources/report.gif" type="image/gif"/><title>praktikum</title><script type="text/javascript" src="jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="jacoco-sessions.html" class="el_session">Sessions</a></span><span class="el_report">praktikum</span></div><h1>praktikum</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">165 of 349</td><td class="ctr2">52 %</td><td class="bar">0 of 4</td><td class="ctr2">100 %</td><td class="ctr1">5</td><td class="ctr2">22</td><td class="ctr1">29</td><td class="ctr2">69</td><td class="ctr1">5</td><td class="ctr2">20</td><td class="ctr1">2</td><td class="ctr2">6</td></tr></tfoot><tbody><tr><td id="a0"><a href="praktikum/index.html" class="el_package">praktikum</a></td><td class="bar" id="b0"><img src="jacoco-resources/redbar.gif" width="56" height="10" title="165" alt="165"/><img src="jacoco-resources/greenbar.gif" width="63" height="10" title="184" alt="184"/></td><td class="ctr2" id="c0">52 %</td><td class="bar" id="d0"><img src="jacoco-resources/greenbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">100 %</td><td class="ctr1" id="f0">5</td><td class="ctr2" id="g0">22</td><td class="ctr1" id="h0">29</td><td class="ctr2" id="i0">69</td><td class="ctr1" id="j0">5</td><td class="ctr2" id="k0">20</td><td class="ctr1" id="l0">2</td><td class="ctr2" id="m0">6</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.11.202310140853</span></div></body></html>