use of ml.comet.experiment.impl.constants.FormParamName.METADATA in project comet-java-sdk by comet-ml.
the class ConnectionUtilsTest method testCreatePostFormRequest.
@Test
public void testCreatePostFormRequest() {
// Create test data
//
String url = "http://test.com" + ApiEndpoints.ADD_ASSET;
Map<QueryParamName, String> params = new HashMap<QueryParamName, String>() {
{
put(EXPERIMENT_KEY, "someValue");
put(OVERWRITE, Boolean.toString(true));
}
};
Map<FormParamName, Object> formParams = new HashMap<FormParamName, Object>() {
{
put(METADATA, "some string");
put(LINK, "https://some.site.com");
}
};
// Create request
//
Request r = ConnectionUtils.createPostFormRequest(url, params, formParams);
this.validateRequest(r, url, params, POST, MULTIPART_FORM_DATA.toString());
// Check body parts
//
assertEquals(2, r.getBodyParts().size(), "wrong number of body parts");
assertTrue(r.getBodyParts().stream().map(part -> (StringPart) part).allMatch(stringPart -> Objects.equals(stringPart.getValue(), formParams.get(FormParamName.valueOf(stringPart.getName().toUpperCase())))));
}
Aggregations