correct failing tests in com.baeldung.repository.FruitRepositoryIntegrationTest
This commit is contained in:
@@ -23,5 +23,5 @@ public interface FruitRepository extends JpaRepository<Fruit, Long> {
|
||||
|
||||
@Modifying
|
||||
@Query("delete from Fruit f where f.name=:name or f.color=:color")
|
||||
List<Fruit> deleteFruits(@Param("name") String name, @Param("color") String color);
|
||||
int deleteFruits(@Param("name") String name, @Param("color") String color);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.baeldung.repository;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,9 +68,8 @@ class FruitRepositoryIntegrationTest {
|
||||
@Sql(scripts = { "/test-fruit-data.sql" })
|
||||
public void givenFruits_WhenDeletedByColorOrName_ThenDeletedFruitsShouldReturn() {
|
||||
|
||||
List<Fruit> fruits = fruitRepository.deleteFruits("apple", "green");
|
||||
int deletedCount = fruitRepository.deleteFruits("apple", "green");
|
||||
|
||||
assertEquals("number of fruits are not matching", 3, fruits.size());
|
||||
fruits.forEach(fruit -> assertTrue("Its not a green fruit or apple", ("green".equals(fruit.getColor())) || "apple".equals(fruit.getColor())));
|
||||
assertEquals("number of fruits are not matching", 3, deletedCount);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
insert into fruit(id,name,color) values (1,'apple','red');
|
||||
insert into fruit(id,name,color) values (2,'custard apple','green');
|
||||
insert into fruit(id,name,color) values (3,'mango','yellow');
|
||||
truncate table fruit;
|
||||
|
||||
insert into fruit(id,name,color) values (1,'apple','red');
|
||||
insert into fruit(id,name,color) values (2,'custard apple','green');
|
||||
insert into fruit(id,name,color) values (3,'mango','yellow');
|
||||
insert into fruit(id,name,color) values (4,'guava','green');
|
||||
Reference in New Issue
Block a user