Refactored IngredientController to use services.
This commit is contained in:
parent
707f88b70b
commit
04f58c22cc
2 changed files with 27 additions and 39 deletions
|
|
@ -11,6 +11,7 @@ import org.springframework.messaging.simp.SimpMessagingTemplate;
|
|||
import org.springframework.test.context.ActiveProfiles;
|
||||
import server.database.IngredientRepository;
|
||||
import server.WebSocketConfig;
|
||||
import server.service.IngredientService;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
|
@ -20,10 +21,11 @@ import java.util.stream.Stream;
|
|||
|
||||
@DataJpaTest
|
||||
@ActiveProfiles("mock-data-test")
|
||||
@Import(WebSocketConfig.class)
|
||||
@Import({WebSocketConfig.class, IngredientService.class})
|
||||
public class IngredientControllerTest {
|
||||
private final SimpMessagingTemplate template;
|
||||
private final IngredientRepository ingredientRepository;
|
||||
private final IngredientService ingredientService;
|
||||
private IngredientController controller;
|
||||
|
||||
private static final double PROTEIN_BASE = 1.0;
|
||||
|
|
@ -42,8 +44,10 @@ public class IngredientControllerTest {
|
|||
|
||||
@Autowired
|
||||
public IngredientControllerTest(IngredientRepository ingredientRepository,
|
||||
IngredientService ingredientService,
|
||||
SimpMessagingTemplate template) {
|
||||
this.ingredientRepository = ingredientRepository;
|
||||
this.ingredientService = ingredientService;
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +63,7 @@ public class IngredientControllerTest {
|
|||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
controller = new IngredientController(ingredientRepository, template);
|
||||
controller = new IngredientController(ingredientService, template);
|
||||
|
||||
this.createInitialIngredients();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue