use of io.micronaut.http.client.multipart.MultipartBody in project check-ins by objectcomputing.
the class EmployeeHoursFixture method createEmployeeHours.
default List<EmployeeHours> createEmployeeHours() {
final EmployeeHoursServices employeeHoursServices = null;
File file = new File("src/test/java/com/objectcomputing/checkins/services/employee_hours/test.csv");
MultipartBody multipartBody = MultipartBody.builder().addPart("file", "test.csv", new MediaType("text/csv"), file).build();
List<EmployeeHours> employeeHoursList = new ArrayList<>();
try {
InputStream inputStream = new FileInputStream(file);
employeeHoursList = EmployeeaHoursCSVHelper.employeeHrsCsv(inputStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return getEmployeeHoursRepository().saveAll(employeeHoursList);
}
use of io.micronaut.http.client.multipart.MultipartBody in project bi-api by Breeding-Insight.
the class TraitUploadControllerIntegrationTest method putTraitUploadMissingMediaType.
@Test
void putTraitUploadMissingMediaType() {
MultipartBody requestBody = MultipartBody.builder().addPart("file", "test", new byte[1]).build();
Flowable<HttpResponse<String>> call = client.exchange(PUT("/programs/" + validProgram.getId() + "/trait-upload", requestBody).contentType(MediaType.MULTIPART_FORM_DATA_TYPE).cookie(new NettyCookie("phylo-token", "test-registered-user")), String.class);
HttpClientResponseException e = Assertions.assertThrows(HttpClientResponseException.class, () -> {
HttpResponse<String> response = call.blockingFirst();
});
assertEquals(HttpStatus.UNSUPPORTED_MEDIA_TYPE, e.getStatus());
}
Aggregations