@Test
public void testPost() throws URISyntaxException {
DbConnectionProperties sourceDB = new DbConnectionProperties("SourceDBName", "SourceDBDriver", "SourceDBUrl", "SourceDBUserName", "SourceDBPassword");
DbConnectionProperties destinationDB = new DbConnectionProperties("DestinationDBName", "DestinationDBDriver", "DestinationDBUrl", "DestinationDBUserName", "DestinationDBPassword");
Streams streamsAvailablity = new Streams(1, 1, 1, 1);
AgencyRequest agencyRequest = new AgencyRequest();
agencyRequest.setConnectorId(1);
agencyRequest.setJobConfig("/usr/local/workspace/test.config.xml");
agencyRequest.setConnectorName("/usr/local/workspace/test.kjb");
agencyRequest.setRequestId(1);
agencyRequest.setTenantId(1);
agencyRequest.setTenantName("Test Tenant");
agencyRequest.setTimeZone("UTC");
agencyRequest.setSourceDB(sourceDB);
agencyRequest.setDestinationDB(destinationDB);
agencyRequest.setIntervalBatchUnit("d");
agencyRequest.setIntervalBatch(0);
agencyRequest.setIntervalReloadUnit("d");
agencyRequest.setIntervalReload(0);
agencyRequest.setMustUseBatch(1);
agencyRequest.setStreamsAvailablity(streamsAvailablity);
String json = new Gson().toJson(agencyRequest);
System.out.println(json);
System.out.println(uri + "/" + ResourceConstants.JOB_CONFIG);
given().
accept(ContentType.JSON).
contentType(ContentType.JSON).
body(json).
post(new URI(uri + "/" + ResourceConstants.JOB_CONFIG)).
then().
assertThat().
statusCode(HttpStatus.OK_200);
}
当我使用嵌套对象传递json正文时,它会向我抛出一个内部错误" 状态代码500 "如果我传递没有嵌套对象的json字符串
,它会成功