diff --git a/testing-modules/testing-libraries-2/pom.xml b/testing-modules/testing-libraries-2/pom.xml index 7f96280cac..b01a1a918b 100644 --- a/testing-modules/testing-libraries-2/pom.xml +++ b/testing-modules/testing-libraries-2/pom.xml @@ -12,6 +12,15 @@ ../ + + 0.8.6 + 1.19.0 + 1.0.0 + 1.1.0 + 5.6.2 + 3.16.1 + + org.assertj @@ -72,6 +81,36 @@ + + + maven-war-plugin + 2.4 + + false + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + package + + report + + + + + testing-libraries @@ -81,11 +120,5 @@ - - 1.19.0 - 1.0.0 - 1.1.0 - 5.6.2 - 3.16.1 - + diff --git a/testing-modules/testing-libraries-2/src/main/java/com/baeldung/sonarqubeandjacoco/product/Product.java b/testing-modules/testing-libraries-2/src/main/java/com/baeldung/sonarqubeandjacoco/product/Product.java new file mode 100644 index 0000000000..42f103a317 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/main/java/com/baeldung/sonarqubeandjacoco/product/Product.java @@ -0,0 +1,54 @@ +package com.baeldung.sonarqubeandjacoco.product; + +public class Product { + + private int id; + private String name; + private int units; + private double price; + + public Product() { + super(); + } + + public Product(int id, String name, int units, double price) { + super(); + this.id = id; + this.name = name; + this.units = units; + this.price = price; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getUnits() { + return units; + } + + public void setUnits(int units) { + this.units = units; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + +} \ No newline at end of file diff --git a/testing-modules/testing-libraries-2/src/test/java/com/baeldung/sonarqubeandjacoco/product/ProductUnitTest.java b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/sonarqubeandjacoco/product/ProductUnitTest.java new file mode 100644 index 0000000000..da649851e0 --- /dev/null +++ b/testing-modules/testing-libraries-2/src/test/java/com/baeldung/sonarqubeandjacoco/product/ProductUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.sonarqubeandjacoco.product; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import com.baeldung.sonarqubeandjacoco.product.Product; + +public class ProductUnitTest { + + @Test + public void test() { + Product product = new Product(); + product.setId(1); + assertNull(product.getName()); + assert (product.getId() == 1); + } + + @Test + public void testProduct() { + Product product = new Product(1, "product", 1, 2.0); + assertNotNull(product.getName()); + } + +}