@Test
public void formatChangeForUploadedHomeFile() throws Exception {
FormDataMultiPart form = new FormDataMultiPart();
FormDataBodyPart fileBody = new FormDataBodyPart("file", FileUtils.getResourceAsFile("/datasets/csv/pipe.csv"), MediaType.MULTIPART_FORM_DATA_TYPE);
form.bodyPart(fileBody);
form.bodyPart(new FormDataBodyPart("fileName", "pipe"));
doc("uploading a text file");
File file1 = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/upload_start/").queryParam("extension", "csv"))
.buildPost(Entity.entity(form, form.getMediaType())), File.class);
file1 = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/upload_finish/pipe"))
.buildPost(Entity.json(file1.getFileFormat().getFileFormat())), File.class);
final FileFormat defaultFileFormat = file1.getFileFormat().getFileFormat();
assertTrue(defaultFileFormat instanceof TextFileConfig);
assertEquals(",", ((TextFileConfig)defaultFileFormat).getFieldDelimiter());
doc("change the format settings of uploaded file");
final TextFileConfig newFileFormat = (TextFileConfig)defaultFileFormat;
newFileFormat.setFieldDelimiter("|");
final FileFormat updatedFileFormat = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/file_format/pipe"))
.buildPut(Entity.json(newFileFormat)), FileFormatUI.class).getFileFormat();
assertTrue(updatedFileFormat instanceof TextFileConfig);
assertEquals("|", ((TextFileConfig)updatedFileFormat).getFieldDelimiter());
}