-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6e870b
commit 3078842
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/java/br/com/esign/qualidadearsmac/ControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package br.com.esign.qualidadearsmac; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import org.json.JSONException; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.skyscreamer.jsonassert.JSONAssert; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.core.io.ResourceLoader; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
@ContextConfiguration(classes = Application.class) | ||
@RunWith(SpringRunner.class) | ||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) | ||
public class ControllerTest { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@Autowired | ||
private TestRestTemplate restTemplate; | ||
|
||
@Autowired | ||
private ResourceLoader resourceLoader; | ||
|
||
@Test | ||
public void testBoletimEndpoint() throws IOException, JSONException { | ||
Resource boletimResource = resourceLoader.getResource("classpath:boletim.json"); | ||
String expected = new String(Files.readAllBytes(boletimResource.getFile().toPath())); | ||
String url = String.format("http://localhost:%s/boletim?data=26/12/2024", port); | ||
String actual = restTemplate.getForObject(url, String.class); | ||
JSONAssert.assertEquals(expected, actual, false); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters