Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FranckSilvestre/cadbfa3f260e862d415bd0198d0601c0 to your computer and use it in GitHub Desktop.
Save FranckSilvestre/cadbfa3f260e862d415bd0198d0601c0 to your computer and use it in GitHub Desktop.
v1 in OurBusinessProject 2023-2024
package ourbusinessproject;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ProjectControllerIntegrationTest {
@Autowired
private TestRestTemplate restTemplate;
@Autowired
private InitializationService initializationService;
@Test
public void testFindAllProjectsWithEnterprises() {
// when requesting all projects
String body = this.restTemplate.getForObject("/api/projects", String.class);
// then the results provide three projects with their enterprise
assertTrue(body.contains(initializationService.getProject1E1().getTitle()));
assertTrue(body.contains(initializationService.getProject1E2().getTitle()));
assertTrue(body.contains(initializationService.getProject2E1().getTitle()));
assertTrue(body.contains(initializationService.getEnterprise1().getName()));
assertTrue(body.contains(initializationService.getEnterprise2().getName()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment