refactor(test/server): refactor server-side testing
This commit is contained in:
parent
c0add049be
commit
88ef77d858
1 changed files with 18 additions and 2 deletions
|
|
@ -13,6 +13,8 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import server.WebSocketConfig;
|
import server.WebSocketConfig;
|
||||||
|
import server.database.IngredientRepository;
|
||||||
|
import server.database.RecipeIngredientRepository;
|
||||||
import server.database.RecipeRepository;
|
import server.database.RecipeRepository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -45,12 +47,21 @@ public class RecipeControllerTest {
|
||||||
private final RecipeRepository recipeRepository;
|
private final RecipeRepository recipeRepository;
|
||||||
private List<Long> recipeIds;
|
private List<Long> recipeIds;
|
||||||
public static final int NUM_RECIPES = 10;
|
public static final int NUM_RECIPES = 10;
|
||||||
|
private final IngredientRepository ingredientRepository;
|
||||||
|
private final RecipeIngredientRepository recipeIngredientRepository;
|
||||||
|
|
||||||
// Injects a test repository into the test class
|
// Injects a test repository into the test class
|
||||||
@Autowired
|
@Autowired
|
||||||
public RecipeControllerTest(RecipeRepository recipeRepository, SimpMessagingTemplate template) {
|
public RecipeControllerTest(
|
||||||
|
RecipeRepository recipeRepository,
|
||||||
|
SimpMessagingTemplate template,
|
||||||
|
IngredientRepository ingredientRepository,
|
||||||
|
RecipeIngredientRepository recipeIngredientRepository
|
||||||
|
) {
|
||||||
this.recipeRepository = recipeRepository;
|
this.recipeRepository = recipeRepository;
|
||||||
this.template = template;
|
this.template = template;
|
||||||
|
this.ingredientRepository = ingredientRepository;
|
||||||
|
this.recipeIngredientRepository = recipeIngredientRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
@ -59,7 +70,12 @@ public class RecipeControllerTest {
|
||||||
.range(0, NUM_RECIPES)
|
.range(0, NUM_RECIPES)
|
||||||
.mapToObj(x -> new Recipe(null, "Recipe " + x, List.of(), List.of()))
|
.mapToObj(x -> new Recipe(null, "Recipe " + x, List.of(), List.of()))
|
||||||
.toList();
|
.toList();
|
||||||
controller = new RecipeController(recipeRepository, template);
|
controller = new RecipeController(
|
||||||
|
recipeRepository,
|
||||||
|
template,
|
||||||
|
ingredientRepository,
|
||||||
|
recipeIngredientRepository
|
||||||
|
);
|
||||||
Set<String> tags = info.getTags();
|
Set<String> tags = info.getTags();
|
||||||
List<Long> ids = new ArrayList<>();
|
List<Long> ids = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue