Skip to content
Snippets Groups Projects
Commit b50d2d4c authored by Ján Macháček's avatar Ján Macháček Committed by Martin Slovík
Browse files

CI: adding integration tests and artifacts

parent af67ee1b
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,8 @@ variables:
stages:
- build
- test
- unit_test
- integration_test
build:
tags:
......@@ -21,10 +22,32 @@ build:
- ls
- ./mvnw clean install -Dmaven.test.skip=true $MAVEN_CLI_OPTS
test:
unit_test:
tags:
- shared-fi
stage: test
stage: unit_test
script:
- echo "We are testing your project build, $GITLAB_USER_LOGIN"
- ./mvnw test $MAVEN_CLI_OPTS
\ No newline at end of file
- echo "We are testing your project build with unit tests, $GITLAB_USER_LOGIN"
- ./mvnw test $MAVEN_CLI_OPTS
artifacts:
expire_in: 10 min
paths:
- "*/target/surefire-reports/*"
reports:
junit:
- "*/target/surefire-reports/*"
integration_test:
tags:
- shared-fi
stage: integration_test
script:
- echo "We are testing your project build with integration tests, $GITLAB_USER_LOGIN"
- ./mvnw verify $MAVEN_CLI_OPTS
artifacts:
expire_in: 10 min
paths:
- "*/target/failsafe-reports/*"
reports:
junit:
- "*/target/failsafe-reports/*"
\ No newline at end of file
......@@ -3,7 +3,7 @@ package cz.muni.fi.pa165.report.server;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import com.fasterxml.jackson.databind.ObjectMapper;;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -11,9 +11,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.core.io.ByteArrayResource;
import org.springframework.test.web.servlet.MockMvc;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
......@@ -41,16 +39,14 @@ class ReportIT {
ClassLoader classLoader = getClass().getClassLoader();
try(InputStream inputStream = classLoader.getResourceAsStream("sample.pdf")){
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
assert inputStream != null;
byte[] bytes = inputStream.readAllBytes();
ByteArrayResource resource = new ByteArrayResource(bytes);
var response = mockMvc.perform(get("/api/reports/flight/1"))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsByteArray();
assertThat(Arrays.equals(response, resource.getByteArray()));
assertThat(response).isEqualTo(resource.getByteArray());
log.debug("response: {}", response);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
......@@ -62,16 +58,14 @@ class ReportIT {
ClassLoader classLoader = getClass().getClassLoader();
try(InputStream inputStream = classLoader.getResourceAsStream("sample.pdf")){
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
assert inputStream != null;
byte[] bytes = inputStream.readAllBytes();
ByteArrayResource resource = new ByteArrayResource(bytes);
var response = mockMvc.perform(get("/api/reports/airport/1"))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsByteArray();
assertThat(Arrays.equals(response, resource.getByteArray()));
assertThat(response).isEqualTo(resource.getByteArray());
log.debug("response: {}", response);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
......@@ -83,16 +77,14 @@ class ReportIT {
ClassLoader classLoader = getClass().getClassLoader();
try(InputStream inputStream = classLoader.getResourceAsStream("sample.pdf")){
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
assert inputStream != null;
byte[] bytes = inputStream.readAllBytes();
ByteArrayResource resource = new ByteArrayResource(bytes);
var response = mockMvc.perform(get("/api/reports/airplane/1"))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsByteArray();
assertThat(Arrays.equals(response, resource.getByteArray()));
assertThat(response).isEqualTo(resource.getByteArray());
log.debug("response: {}", response);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment