diff --git a/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/AllergyResponseTest.java b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/AllergyResponseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5b2736765a7a40499ea3e70805352af5d8051998 --- /dev/null +++ b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/AllergyResponseTest.java @@ -0,0 +1,55 @@ +package ntnu.idatt2016.v233.SmartMat.dto.response; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class AllergyResponseTest { + + @Test + void testEquals() { + AllergyResponse allergyResponse = AllergyResponse.builder() + .name("test") + .description("test") + .build(); + + AllergyResponse allergyResponse1 = AllergyResponse.builder() + .name("test") + .description("test") + .build(); + + assertEquals(allergyResponse, allergyResponse1); + + allergyResponse1.setName("test2"); + + assertNotEquals(allergyResponse, allergyResponse1); + + allergyResponse1.setName("test"); + + allergyResponse1.setDescription("test2"); + + assertNotEquals(allergyResponse, allergyResponse1); + + assertEquals(allergyResponse, allergyResponse); + + } + + @Test + void testHashCode() { + AllergyResponse allergyResponse = AllergyResponse.builder() + .name("test") + .description("test") + .build(); + + AllergyResponse allergyResponse1 = AllergyResponse.builder() + .name("test") + .description("test") + .build(); + + assertEquals(allergyResponse.hashCode(), allergyResponse1.hashCode()); + + allergyResponse1.setName("test2"); + + assertNotEquals(allergyResponse.hashCode(), allergyResponse1.hashCode()); + } +} \ No newline at end of file diff --git a/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeDetailsTest.java b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeDetailsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0859efb8464015d8b7609a902f50c3a1d50305ad --- /dev/null +++ b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeDetailsTest.java @@ -0,0 +1,55 @@ +package ntnu.idatt2016.v233.SmartMat.dto.response; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class RecipeDetailsTest { + + @Test + void testEquals() { + + RecipeDetails recipeDetails = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + RecipeDetails recipeDetails1 = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + assertEquals(recipeDetails, recipeDetails1); + + recipeDetails1.setRecipeDescription("test2"); + + assertNotEquals(recipeDetails, recipeDetails1); + + recipeDetails1.setRecipeDescription("test"); + + recipeDetails1.setRecipeId(123); + + assertNotEquals(recipeDetails, recipeDetails1); + + assertEquals(recipeDetails, recipeDetails); + + } + + @Test + void testHashCode() { + + RecipeDetails recipeDetails = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + RecipeDetails recipeDetails1 = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + assertEquals(recipeDetails.hashCode(), recipeDetails1.hashCode()); + + recipeDetails1.setRecipeDescription("test2"); + + assertNotEquals(recipeDetails.hashCode(), recipeDetails1.hashCode()); + + + } +} \ No newline at end of file diff --git a/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeWithMatchCountTest.java b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeWithMatchCountTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8a67d631ced67d55c8bd9905e3fc41693414b640 --- /dev/null +++ b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/RecipeWithMatchCountTest.java @@ -0,0 +1,64 @@ +package ntnu.idatt2016.v233.SmartMat.dto.response; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class RecipeWithMatchCountTest { + + @Test + void testEquals() { + RecipeDetails recipeDetails = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + RecipeDetails recipeDetails1 = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + RecipeWithMatchCount recipeWithMatchCount = RecipeWithMatchCount.builder() + .recipeDetails(recipeDetails) + .build(); + + RecipeWithMatchCount recipeWithMatchCount1 = RecipeWithMatchCount.builder() + .recipeDetails(recipeDetails1) + .build(); + + assertEquals(recipeWithMatchCount, recipeWithMatchCount1); + + recipeWithMatchCount1.setMatchCount(123); + + assertNotEquals(recipeWithMatchCount, recipeWithMatchCount1); + + recipeWithMatchCount1.setMatchCount(0); + + assertEquals(recipeWithMatchCount, recipeWithMatchCount1); + + + } + + @Test + void testHashCode() { + RecipeDetails recipeDetails = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + RecipeDetails recipeDetails1 = RecipeDetails.builder() + .recipeDescription("test") + .build(); + + RecipeWithMatchCount recipeWithMatchCount = RecipeWithMatchCount.builder() + .recipeDetails(recipeDetails) + .build(); + + RecipeWithMatchCount recipeWithMatchCount1 = RecipeWithMatchCount.builder() + .recipeDetails(recipeDetails1) + .build(); + + assertEquals(recipeWithMatchCount.hashCode(), recipeWithMatchCount1.hashCode()); + + recipeWithMatchCount1.setMatchCount(123); + + assertNotEquals(recipeWithMatchCount.hashCode(), recipeWithMatchCount1.hashCode()); + } +} \ No newline at end of file diff --git a/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/WeeklyMenuResponseTest.java b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/WeeklyMenuResponseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e474c6ae5dc844359b0cce49a170992790c48152 --- /dev/null +++ b/src/test/java/ntnu/idatt2016/v233/SmartMat/dto/response/WeeklyMenuResponseTest.java @@ -0,0 +1,75 @@ +package ntnu.idatt2016.v233.SmartMat.dto.response; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class WeeklyMenuResponseTest { + + @Test + void testEquals() { + WeeklyMenuResponse weeklyMenuResponse = WeeklyMenuResponse.builder() + .recipeDescription("test") + .matchingProducts(123L) + .build(); + + WeeklyMenuResponse weeklyMenuResponse1 = WeeklyMenuResponse.builder() + .recipeDescription("test") + .matchingProducts(123L) + .build(); + + assertEquals(weeklyMenuResponse, weeklyMenuResponse1); + + weeklyMenuResponse1.setRecipeDescription("test2"); + + assertNotEquals(weeklyMenuResponse, weeklyMenuResponse1); + + weeklyMenuResponse1.setRecipeDescription("test"); + + weeklyMenuResponse1.setMatchingProducts(321L); + + assertNotEquals(weeklyMenuResponse, weeklyMenuResponse1); + + weeklyMenuResponse1.setMatchingProducts(123L); + + weeklyMenuResponse1.setRecipeId(123); + + assertNotEquals(weeklyMenuResponse, weeklyMenuResponse1); + + assertEquals(weeklyMenuResponse, weeklyMenuResponse); + + } + + @Test + void testHashCode() { + WeeklyMenuResponse weeklyMenuResponse = WeeklyMenuResponse.builder() + .recipeDescription("test") + .matchingProducts(123L) + .build(); + + WeeklyMenuResponse weeklyMenuResponse1 = WeeklyMenuResponse.builder() + .recipeDescription("test") + .matchingProducts(123L) + .build(); + + assertEquals(weeklyMenuResponse.hashCode(), weeklyMenuResponse1.hashCode()); + + weeklyMenuResponse1.setRecipeDescription("test2"); + + assertNotEquals(weeklyMenuResponse.hashCode(), weeklyMenuResponse1.hashCode()); + + weeklyMenuResponse1.setRecipeDescription("test"); + + weeklyMenuResponse1.setMatchingProducts(321L); + + assertNotEquals(weeklyMenuResponse.hashCode(), weeklyMenuResponse1.hashCode()); + + weeklyMenuResponse1.setMatchingProducts(123L); + + weeklyMenuResponse1.setRecipeId(123); + + assertNotEquals(weeklyMenuResponse.hashCode(), weeklyMenuResponse1.hashCode()); + + assertEquals(weeklyMenuResponse.hashCode(), weeklyMenuResponse.hashCode()); + } +} \ No newline at end of file