diff --git a/.circleci/config.yml b/.circleci/config.yml
index ffb39fc..1f2b6c2 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -7,7 +7,7 @@ jobs:
build:
docker:
# specify the version you desire here
- - image: circleci/openjdk:8-jdk
+ - image: circleci/openjdk:17.0.5
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
diff --git a/pom.xml b/pom.xml
index c616746..2d1db00 100755
--- a/pom.xml
+++ b/pom.xml
@@ -14,17 +14,21 @@
org.springframework.boot
spring-boot-starter-parent
- 2.1.0.RELEASE
+ 2.7.2
UTF-8
UTF-8
- 1.8
+ 17
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
org.springframework.boot
spring-boot-starter-data-jpa
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e45c501..7d80715 100755
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1 +1,4 @@
-logging.level.guru.springframework=debug
\ No newline at end of file
+logging.level.guru.springframework=debug
+spring.h2.console.enabled=true
+spring.datasource.url=jdbc:h2:mem:mydb
+spring.jpa.defer-datasource-initialization=true
\ No newline at end of file
diff --git a/src/test/java/guru/springframework/Spring5RecipeAppApplicationTests.java b/src/test/java/guru/springframework/Spring5RecipeAppApplicationTests.java
index 775dc5f..ecdca7f 100755
--- a/src/test/java/guru/springframework/Spring5RecipeAppApplicationTests.java
+++ b/src/test/java/guru/springframework/Spring5RecipeAppApplicationTests.java
@@ -1,11 +1,10 @@
package guru.springframework;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
+
@SpringBootTest
public class Spring5RecipeAppApplicationTests {
diff --git a/src/test/java/guru/springframework/controllers/ImageControllerTest.java b/src/test/java/guru/springframework/controllers/ImageControllerTest.java
index f745e6a..6b6be37 100755
--- a/src/test/java/guru/springframework/controllers/ImageControllerTest.java
+++ b/src/test/java/guru/springframework/controllers/ImageControllerTest.java
@@ -3,8 +3,8 @@
import guru.springframework.commands.RecipeCommand;
import guru.springframework.services.ImageService;
import guru.springframework.services.RecipeService;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -12,7 +12,7 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
@@ -30,9 +30,9 @@ public class ImageControllerTest {
MockMvc mockMvc;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
controller = new ImageController(imageService, recipeService);
mockMvc = MockMvcBuilders.standaloneSetup(controller)
diff --git a/src/test/java/guru/springframework/controllers/IndexControllerTest.java b/src/test/java/guru/springframework/controllers/IndexControllerTest.java
index 8f31456..b86ee4c 100755
--- a/src/test/java/guru/springframework/controllers/IndexControllerTest.java
+++ b/src/test/java/guru/springframework/controllers/IndexControllerTest.java
@@ -2,8 +2,8 @@
import guru.springframework.domain.Recipe;
import guru.springframework.services.RecipeService;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -14,7 +14,7 @@
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -33,9 +33,9 @@ public class IndexControllerTest {
IndexController controller;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
controller = new IndexController(recipeService);
}
diff --git a/src/test/java/guru/springframework/controllers/IngredientControllerTest.java b/src/test/java/guru/springframework/controllers/IngredientControllerTest.java
index 8a82548..60b9e6e 100755
--- a/src/test/java/guru/springframework/controllers/IngredientControllerTest.java
+++ b/src/test/java/guru/springframework/controllers/IngredientControllerTest.java
@@ -5,8 +5,8 @@
import guru.springframework.services.IngredientService;
import guru.springframework.services.RecipeService;
import guru.springframework.services.UnitOfMeasureService;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.MediaType;
@@ -36,7 +36,7 @@ public class IngredientControllerTest {
MockMvc mockMvc;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
diff --git a/src/test/java/guru/springframework/controllers/RecipeControllerTest.java b/src/test/java/guru/springframework/controllers/RecipeControllerTest.java
index 56c0d87..9aed39d 100755
--- a/src/test/java/guru/springframework/controllers/RecipeControllerTest.java
+++ b/src/test/java/guru/springframework/controllers/RecipeControllerTest.java
@@ -4,8 +4,8 @@
import guru.springframework.domain.Recipe;
import guru.springframework.exceptions.NotFoundException;
import guru.springframework.services.RecipeService;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.MediaType;
@@ -31,7 +31,7 @@ public class RecipeControllerTest {
MockMvc mockMvc;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
diff --git a/src/test/java/guru/springframework/converters/CategoryCommandToCategoryTest.java b/src/test/java/guru/springframework/converters/CategoryCommandToCategoryTest.java
index cc7298e..546c778 100755
--- a/src/test/java/guru/springframework/converters/CategoryCommandToCategoryTest.java
+++ b/src/test/java/guru/springframework/converters/CategoryCommandToCategoryTest.java
@@ -2,18 +2,18 @@
import guru.springframework.commands.CategoryCommand;
import guru.springframework.domain.Category;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class CategoryCommandToCategoryTest {
- public static final Long ID_VALUE = new Long(1L);
+ public static final Long ID_VALUE = Long.valueOf(1L);
public static final String DESCRIPTION = "description";
CategoryCommandToCategory conveter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
conveter = new CategoryCommandToCategory();
}
diff --git a/src/test/java/guru/springframework/converters/CategoryToCategoryCommandTest.java b/src/test/java/guru/springframework/converters/CategoryToCategoryCommandTest.java
index 1cf4445..b838d1f 100755
--- a/src/test/java/guru/springframework/converters/CategoryToCategoryCommandTest.java
+++ b/src/test/java/guru/springframework/converters/CategoryToCategoryCommandTest.java
@@ -2,21 +2,21 @@
import guru.springframework.commands.CategoryCommand;
import guru.springframework.domain.Category;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Created by jt on 6/21/17.
*/
public class CategoryToCategoryCommandTest {
- public static final Long ID_VALUE = new Long(1L);
+ public static final Long ID_VALUE = Long.valueOf(1L);
public static final String DESCRIPTION = "descript";
CategoryToCategoryCommand convter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
convter = new CategoryToCategoryCommand();
}
diff --git a/src/test/java/guru/springframework/converters/IngredientCommandToIngredientTest.java b/src/test/java/guru/springframework/converters/IngredientCommandToIngredientTest.java
index ec7c275..38b8147 100755
--- a/src/test/java/guru/springframework/converters/IngredientCommandToIngredientTest.java
+++ b/src/test/java/guru/springframework/converters/IngredientCommandToIngredientTest.java
@@ -4,24 +4,25 @@
import guru.springframework.commands.UnitOfMeasureCommand;
import guru.springframework.domain.Ingredient;
import guru.springframework.domain.Recipe;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+
public class IngredientCommandToIngredientTest {
public static final Recipe RECIPE = new Recipe();
public static final BigDecimal AMOUNT = new BigDecimal("1");
public static final String DESCRIPTION = "Cheeseburger";
- public static final Long ID_VALUE = new Long(1L);
- public static final Long UOM_ID = new Long(2L);
+ public static final Long ID_VALUE = Long.valueOf(1L);
+ public static final Long UOM_ID = Long.valueOf(2L);
IngredientCommandToIngredient converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new IngredientCommandToIngredient(new UnitOfMeasureCommandToUnitOfMeasure());
}
diff --git a/src/test/java/guru/springframework/converters/IngredientToIngredientCommandTest.java b/src/test/java/guru/springframework/converters/IngredientToIngredientCommandTest.java
index 40601af..e004713 100755
--- a/src/test/java/guru/springframework/converters/IngredientToIngredientCommandTest.java
+++ b/src/test/java/guru/springframework/converters/IngredientToIngredientCommandTest.java
@@ -4,12 +4,13 @@
import guru.springframework.domain.Ingredient;
import guru.springframework.domain.Recipe;
import guru.springframework.domain.UnitOfMeasure;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* Created by jt on 6/21/17.
@@ -19,13 +20,13 @@ public class IngredientToIngredientCommandTest {
public static final Recipe RECIPE = new Recipe();
public static final BigDecimal AMOUNT = new BigDecimal("1");
public static final String DESCRIPTION = "Cheeseburger";
- public static final Long UOM_ID = new Long(2L);
- public static final Long ID_VALUE = new Long(1L);
+ public static final Long UOM_ID = Long.valueOf(2L);
+ public static final Long ID_VALUE = Long.valueOf(1L);
IngredientToIngredientCommand converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new IngredientToIngredientCommand(new UnitOfMeasureToUnitOfMeasureCommand());
}
diff --git a/src/test/java/guru/springframework/converters/NotesCommandToNotesTest.java b/src/test/java/guru/springframework/converters/NotesCommandToNotesTest.java
index 855f02e..67bef39 100755
--- a/src/test/java/guru/springframework/converters/NotesCommandToNotesTest.java
+++ b/src/test/java/guru/springframework/converters/NotesCommandToNotesTest.java
@@ -2,18 +2,18 @@
import guru.springframework.commands.NotesCommand;
import guru.springframework.domain.Notes;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class NotesCommandToNotesTest {
- public static final Long ID_VALUE = new Long(1L);
+ public static final Long ID_VALUE = Long.valueOf(1L);
public static final String RECIPE_NOTES = "Notes";
NotesCommandToNotes converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new NotesCommandToNotes();
diff --git a/src/test/java/guru/springframework/converters/NotesToNotesCommandTest.java b/src/test/java/guru/springframework/converters/NotesToNotesCommandTest.java
index bac0ac0..2b2b615 100755
--- a/src/test/java/guru/springframework/converters/NotesToNotesCommandTest.java
+++ b/src/test/java/guru/springframework/converters/NotesToNotesCommandTest.java
@@ -2,21 +2,22 @@
import guru.springframework.commands.NotesCommand;
import guru.springframework.domain.Notes;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.Assert.*;
/**
* Created by jt on 6/21/17.
*/
public class NotesToNotesCommandTest {
- public static final Long ID_VALUE = new Long(1L);
+ public static final Long ID_VALUE = Long.valueOf(1L);
public static final String RECIPE_NOTES = "Notes";
NotesToNotesCommand converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new NotesToNotesCommand();
}
diff --git a/src/test/java/guru/springframework/converters/RecipeCommandToRecipeTest.java b/src/test/java/guru/springframework/converters/RecipeCommandToRecipeTest.java
index bbacedb..5259dfb 100755
--- a/src/test/java/guru/springframework/converters/RecipeCommandToRecipeTest.java
+++ b/src/test/java/guru/springframework/converters/RecipeCommandToRecipeTest.java
@@ -6,10 +6,10 @@
import guru.springframework.commands.RecipeCommand;
import guru.springframework.domain.Difficulty;
import guru.springframework.domain.Recipe;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class RecipeCommandToRecipeTest {
public static final Long RECIPE_ID = 1L;
@@ -30,7 +30,7 @@ public class RecipeCommandToRecipeTest {
RecipeCommandToRecipe converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new RecipeCommandToRecipe(new CategoryCommandToCategory(),
new IngredientCommandToIngredient(new UnitOfMeasureCommandToUnitOfMeasure()),
diff --git a/src/test/java/guru/springframework/converters/RecipeToRecipeCommandTest.java b/src/test/java/guru/springframework/converters/RecipeToRecipeCommandTest.java
index 9bf0d75..c3c74aa 100755
--- a/src/test/java/guru/springframework/converters/RecipeToRecipeCommandTest.java
+++ b/src/test/java/guru/springframework/converters/RecipeToRecipeCommandTest.java
@@ -2,10 +2,10 @@
import guru.springframework.commands.RecipeCommand;
import guru.springframework.domain.*;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class RecipeToRecipeCommandTest {
@@ -25,7 +25,7 @@ public class RecipeToRecipeCommandTest {
public static final Long NOTES_ID = 9L;
RecipeToRecipeCommand converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new RecipeToRecipeCommand(
new CategoryToCategoryCommand(),
diff --git a/src/test/java/guru/springframework/converters/UnitOfMeasureCommandToUnitOfMeasureTest.java b/src/test/java/guru/springframework/converters/UnitOfMeasureCommandToUnitOfMeasureTest.java
index 820f5d5..8e66129 100755
--- a/src/test/java/guru/springframework/converters/UnitOfMeasureCommandToUnitOfMeasureTest.java
+++ b/src/test/java/guru/springframework/converters/UnitOfMeasureCommandToUnitOfMeasureTest.java
@@ -2,19 +2,19 @@
import guru.springframework.commands.UnitOfMeasureCommand;
import guru.springframework.domain.UnitOfMeasure;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class UnitOfMeasureCommandToUnitOfMeasureTest {
public static final String DESCRIPTION = "description";
- public static final Long LONG_VALUE = new Long(1L);
+ public static final Long LONG_VALUE = Long.valueOf(1L);
UnitOfMeasureCommandToUnitOfMeasure converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new UnitOfMeasureCommandToUnitOfMeasure();
diff --git a/src/test/java/guru/springframework/converters/UnitOfMeasureToUnitOfMeasureCommandTest.java b/src/test/java/guru/springframework/converters/UnitOfMeasureToUnitOfMeasureCommandTest.java
index 68a3257..cea508a 100755
--- a/src/test/java/guru/springframework/converters/UnitOfMeasureToUnitOfMeasureCommandTest.java
+++ b/src/test/java/guru/springframework/converters/UnitOfMeasureToUnitOfMeasureCommandTest.java
@@ -2,10 +2,10 @@
import guru.springframework.commands.UnitOfMeasureCommand;
import guru.springframework.domain.UnitOfMeasure;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Created by jt on 6/21/17.
@@ -13,11 +13,11 @@
public class UnitOfMeasureToUnitOfMeasureCommandTest {
public static final String DESCRIPTION = "description";
- public static final Long LONG_VALUE = new Long(1L);
+ public static final Long LONG_VALUE = Long.valueOf(1L);
UnitOfMeasureToUnitOfMeasureCommand converter;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
converter = new UnitOfMeasureToUnitOfMeasureCommand();
}
diff --git a/src/test/java/guru/springframework/domain/CategoryTest.java b/src/test/java/guru/springframework/domain/CategoryTest.java
index 11badc4..c10b9d5 100755
--- a/src/test/java/guru/springframework/domain/CategoryTest.java
+++ b/src/test/java/guru/springframework/domain/CategoryTest.java
@@ -1,9 +1,9 @@
package guru.springframework.domain;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Created by jt on 6/17/17.
@@ -12,7 +12,7 @@ public class CategoryTest {
Category category;
- @Before
+ @BeforeEach
public void setUp(){
category = new Category();
}
diff --git a/src/test/java/guru/springframework/repositories/UnitOfMeasureRepositoryIT.java b/src/test/java/guru/springframework/repositories/UnitOfMeasureRepositoryIT.java
index b934959..6b834da 100755
--- a/src/test/java/guru/springframework/repositories/UnitOfMeasureRepositoryIT.java
+++ b/src/test/java/guru/springframework/repositories/UnitOfMeasureRepositoryIT.java
@@ -1,28 +1,27 @@
package guru.springframework.repositories;
import guru.springframework.domain.UnitOfMeasure;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Created by jt on 6/17/17.
*/
-@RunWith(SpringRunner.class)
@DataJpaTest
public class UnitOfMeasureRepositoryIT {
@Autowired
UnitOfMeasureRepository unitOfMeasureRepository;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
}
diff --git a/src/test/java/guru/springframework/services/ImageServiceImplTest.java b/src/test/java/guru/springframework/services/ImageServiceImplTest.java
index a8e5c90..9bc48f2 100755
--- a/src/test/java/guru/springframework/services/ImageServiceImplTest.java
+++ b/src/test/java/guru/springframework/services/ImageServiceImplTest.java
@@ -2,8 +2,8 @@
import guru.springframework.domain.Recipe;
import guru.springframework.repositories.RecipeRepository;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -12,7 +12,7 @@
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
@@ -23,7 +23,7 @@ public class ImageServiceImplTest {
ImageService imageService;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
diff --git a/src/test/java/guru/springframework/services/IngredientServiceImplTest.java b/src/test/java/guru/springframework/services/IngredientServiceImplTest.java
index 49d53b1..4ebcade 100755
--- a/src/test/java/guru/springframework/services/IngredientServiceImplTest.java
+++ b/src/test/java/guru/springframework/services/IngredientServiceImplTest.java
@@ -9,14 +9,14 @@
import guru.springframework.domain.Recipe;
import guru.springframework.repositories.RecipeRepository;
import guru.springframework.repositories.UnitOfMeasureRepository;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.*;
@@ -39,9 +39,9 @@ public IngredientServiceImplTest() {
this.ingredientCommandToIngredient = new IngredientCommandToIngredient(new UnitOfMeasureCommandToUnitOfMeasure());
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
ingredientService = new IngredientServiceImpl(ingredientToIngredientCommand, ingredientCommandToIngredient,
recipeRepository, unitOfMeasureRepository);
diff --git a/src/test/java/guru/springframework/services/RecipeServiceIT.java b/src/test/java/guru/springframework/services/RecipeServiceIT.java
index f8702b9..0e2c59a 100755
--- a/src/test/java/guru/springframework/services/RecipeServiceIT.java
+++ b/src/test/java/guru/springframework/services/RecipeServiceIT.java
@@ -5,20 +5,18 @@
import guru.springframework.converters.RecipeToRecipeCommand;
import guru.springframework.domain.Recipe;
import guru.springframework.repositories.RecipeRepository;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Created by jt on 6/21/17.
*/
-@RunWith(SpringRunner.class)
@SpringBootTest
public class RecipeServiceIT {
diff --git a/src/test/java/guru/springframework/services/RecipeServiceImplTest.java b/src/test/java/guru/springframework/services/RecipeServiceImplTest.java
index d16897c..0059377 100755
--- a/src/test/java/guru/springframework/services/RecipeServiceImplTest.java
+++ b/src/test/java/guru/springframework/services/RecipeServiceImplTest.java
@@ -7,8 +7,8 @@
import guru.springframework.domain.Recipe;
import guru.springframework.exceptions.NotFoundException;
import guru.springframework.repositories.RecipeRepository;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -16,9 +16,11 @@
import java.util.Optional;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
+import static org.springframework.test.util.AssertionErrors.assertNotNull;
/**
* Created by jt on 6/17/17.
@@ -36,9 +38,9 @@ public class RecipeServiceImplTest {
@Mock
RecipeCommandToRecipe recipeCommandToRecipe;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
recipeService = new RecipeServiceImpl(recipeRepository, recipeCommandToRecipe, recipeToRecipeCommand);
}
@@ -58,16 +60,16 @@ public void getRecipeByIdTest() throws Exception {
verify(recipeRepository, never()).findAll();
}
- @Test(expected = NotFoundException.class)
+ @Test
public void getRecipeByIdTestNotFound() throws Exception {
- Optional recipeOptional = Optional.empty();
-
- when(recipeRepository.findById(anyLong())).thenReturn(recipeOptional);
-
- Recipe recipeReturned = recipeService.findById(1L);
-
- //should go boom
+ try{
+ Optional recipeOptional = Optional.empty();
+ when(recipeRepository.findById(anyLong())).thenReturn(recipeOptional);
+ Recipe recipeReturned = recipeService.findById(1L);
+ }catch(Exception e){
+ assertThat(e, instanceOf(NotFoundException.class));
+ }
}
@Test
diff --git a/src/test/java/guru/springframework/services/UnitOfMeasureServiceImplTest.java b/src/test/java/guru/springframework/services/UnitOfMeasureServiceImplTest.java
index d055bd5..5c0130e 100755
--- a/src/test/java/guru/springframework/services/UnitOfMeasureServiceImplTest.java
+++ b/src/test/java/guru/springframework/services/UnitOfMeasureServiceImplTest.java
@@ -4,15 +4,15 @@
import guru.springframework.converters.UnitOfMeasureToUnitOfMeasureCommand;
import guru.springframework.domain.UnitOfMeasure;
import guru.springframework.repositories.UnitOfMeasureRepository;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
public class UnitOfMeasureServiceImplTest {
@@ -23,9 +23,9 @@ public class UnitOfMeasureServiceImplTest {
@Mock
UnitOfMeasureRepository unitOfMeasureRepository;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
service = new UnitOfMeasureServiceImpl(unitOfMeasureRepository, unitOfMeasureToUnitOfMeasureCommand);
}