当从BE服务获得响应时,我正在使用Gson的rest-asserted进行测试。我正在创建一个POJO对象,该对象反序列化JSON并创建一个对象,但由于某种原因,所有对象字段都为空。仅供参考,我在另一个API调用中使用了相同的做法,它工作正常,但在本例中,它不工作。
{
"allLanguages": [
"English"
],
"Messages": [
{
"Messages": null
}
],
"Content": [
{
"Subject": "EmailWithDOCAttachmentJCBKMJJ Test Email with docx attachment"
},
{
"Content": "An email includes Docx file as an attachment"
},
{
"Content Html": "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w=\"urn:schemas-microsoft-com:office:word\" xmlns:m=\"http://schemas.microsoft.com/office/2004/12/omml\" xmlns=\"http://www.w3.org/TR/REC-html40\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\"><meta name=\"Generator\" content=\"Microsoft Word 15 (filtered medium)\"><style><!--/* Font Definitions */@font-face{font-family:\"Cambria Math\";panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{margin:0cm;font-size:11.0pt;font-family:\"Calibri\",sans-serif;}span.EmailStyle17{mso-style-type:personal-compose;font-family:\"Calibri\",sans-serif;color:windowtext;}.MsoChpDefault{mso-style-type:export-only;font-family:\"Calibri\",sans-serif;}@page WordSection1{size:612.0pt 792.0pt;margin:72.0pt 72.0pt 72.0pt 72.0pt;}div.WordSection1{page:WordSection1;}--></style></head><body lang=\"en-IL\" link=\"#0563C1\" vlink=\"#954F72\" style=\"word-wrap:break-word\"><div class=\"WordSection1\"><p class=\"MsoNormal\"><span lang=\"EN-US\">An email includes Docx file as an attachment<o:p></o:p></span></p></div></body></html>"
},
{
"Record Date": "2023-01-30 12:27:53.000"
}
],
"Generic": [
{
"Date": "2023-01-30 12:27:53.000"
},
{
"Date Added": "2023-01-30 10:30:51.146"
},
{
"Date Time Created": "2023-01-30 12:27:53.000"
},
{
"Date Time Received": "2023-01-30 10:27:58.090"
},
{
"Index Name": "dr_smtpemail_2023.01.01_999"
},
{
"Ecomm Id": "6BF42EAC97D5C20A071D34AB7BCE7B8C"
},
{
"archive Ids": "[2]"
},
{
},
{
},
{
"Record Date": "2023-01-30 12:27:53.000"
},
{
"Ecomm Type": "E-Mail"
},
{
"Platform Name": "SMTPEmail"
},
{
},
{
"Retention date": "2023-07-31 12:27:53.000"
},
{
"archiveRoot": "E-Mail/SMTPEmail/2023/01/30"
},
{
"platformDisplayName": "SMTP Email"
}
],
"Product": [
{
"Product": [
]
}
],
"transcribedMessages": [
{
"transcribedMessages": null
}
],
"Participants": [
{
"Participants": [
{
"Participant Account Bsk Country": null,
"Participant Is Surveillance Data": null,
"Participant Emp Global ID": null,
"Participant JOB ID": null,
"Participant Account Name": null,
"Participant AIM": null,
"Participant External Company": null,
"Participant Parent Group Display": null,
"Participant Type": "unknown",
"Participant LEV5": null,
"Participant First Name": null,
"Participant LEV4": null,
"Participant LEV6": null,
"Participant YJ": null,
"Participant Is Record Keeping": null,
"Participant Email": "monitor@ggg.com",
"Participant Unique Id": "monitor@ggg.com",
"Participant Manager Name": null,
"Participant Skype": null,
"Participant Bank Department": null,
"Participant Department Display": null,
"Participant Business Unit": null,
"Participant Division": null,
"Participant City": null,
"Participant Account Manager": null,
"Participant Department": null,
"Participant Name For Viewer": null,
"Participant Emp Sub Unit": null,
"Participant Job Description": null,
"Participant TCCID": null,
"Nationality Code": null,
"Participant Name": null,
"Participant Org Sub Unit": null,
"Participant Yahoo": null,
"Participant Id": null,
"Participant Display Name": null,
"Participant Region": null,
"Participant Trader ID": null,
"Participant Parent Group": null,
"Participant Manager ID": null,
"Participant Org Unit Name": null,
"Participant Country Code": null,
"Participant CLI": null,
"Participant Is Internal": "false",
"Participant Employee Status": null,
"Participant Last Name": null,
"Participant Delivery Type": null,
"Participant Nationality Code": null,
"Participant IMID": null,
"Participant SSN": null,
"Participant Account Number": null,
"Participant Secondary Email": null,
"Participant Role Type Name": null
},
{
"Participant Account Bsk Country": null,
"Participant Is Surveillance Data": "true",
"Participant Emp Global ID": "employeeIdGlobal-Adele",
"Participant JOB ID": "jobIdAdele",
"Participant Account Name": null,
"Participant AIM": null,
"Participant External Company": null,
"Participant Parent Group Display": "monitored group",
"Participant Type": "customer",
"Participant LEV5": "lev5-Adele",
"Participant First Name": "Adele",
"Participant LEV4": "lev4-Adele",
"Participant LEV6": "lev6-Adele",
"Participant YJ": null,
"Participant Is Record Keeping": "false",
"Participant Email": "adelev@ggg.onmicrosoft.com",
"Participant Unique Id": "Z778714Adele",
"Participant Manager Name": "manager-for Adele",
"Participant Skype": null,
"Participant Bank Department": null,
"Participant Department Display": "monitored group",
"Participant Business Unit": "businessUnit-Adele",
"Participant Division": "division-Adele",
"Participant City": "City-Adele",
"Participant Account Manager": null,
"Participant Department": "monitored_system_group",
"Participant Name For Viewer": null,
"Participant Emp Sub Unit": "division-Adele",
"Participant Job Description": "jobDescription-Adele",
"Participant TCCID": null,
"Nationality Code": "nationalityCode-Adele",
"Participant Name": "Adele Vance",
"Participant Org Sub Unit": "organizationalUnit-Adele",
"Participant Yahoo": null,
"Participant Id": "Z778714Adele",
"Participant Display Name": null,
"Participant Region": "AM",
"Participant Trader ID": null,
"Participant Parent Group": "monitored_system_group",
"Participant Manager ID": "11005328",
"Participant Org Unit Name": "orgUnitId-Adele",
"Participant Country Code": null,
"Participant CLI": null,
"Participant Is Internal": "true",
"Participant Employee Status": null,
"Participant Last Name": "Vance",
"Participant Delivery Type": null,
"Participant Nationality Code": "nationalityCode-Adele",
"Participant IMID": null,
"Participant SSN": null,
"Participant Account Number": null,
"Participant Secondary Email": null,
"Participant Role Type Name": null
},
{
"Participant Account Bsk Country": null,
"Participant Is Surveillance Data": "true",
"Participant Emp Global ID": "employeeIdGlobal-Alex",
"Participant JOB ID": "jobIdAlex",
"Participant Account Name": null,
"Participant AIM": null,
"Participant External Company": null,
"Participant Parent Group Display": "monitored group",
"Participant Type": "advisor",
"Participant LEV5": "lev5-Alex",
"Participant First Name": "Alex",
"Participant LEV4": "lev4-Alex",
"Participant LEV6": "lev6-Alex",
"Participant YJ": null,
"Participant Is Record Keeping": "false",
"Participant Email": "alexw@gggg.onmicrosoft.com",
"Participant Unique Id": "N306800Alex",
"Participant Manager Name": "manager-for Alex",
"Participant Skype": null,
"Participant Bank Department": null,
"Participant Department Display": "ggg monitored group",
"Participant Business Unit": "businessUnit-Alex",
"Participant Division": "division-Alex",
"Participant City": "City-Alex",
"Participant Account Manager": null,
"Participant Department": "monitored_system_group",
"Participant Name For Viewer": null,
"Participant Emp Sub Unit": "division-Alex",
"Participant Job Description": "jobDescription-Alex",
"Participant TCCID": null,
"Nationality Code": "nationalityCode-Alex",
"Participant Name": "Alex W",
"Participant Org Sub Unit": "organizationalUnit-Alex",
"Participant Yahoo": null,
"Participant Id": "N306800Alex",
"Participant Display Name": null,
"Participant Region": "WB",
"Participant Trader ID": null,
"Participant Parent Group": "monitored_system_group",
"Participant Manager ID": "53002941",
"Participant Org Unit Name": "orgUnitId-Alex",
"Participant Country Code": null,
"Participant CLI": null,
"Participant Is Internal": "true",
"Participant Employee Status": null,
"Participant Last Name": "W",
"Participant Delivery Type": null,
"Participant Nationality Code": "nationalityCode-Alex",
"Participant IMID": null,
"Participant SSN": null,
"Participant Account Number": null,
"Participant Secondary Email": null,
"Participant Role Type Name": null
}
]
},
{
"Participants Count": "3"
}
],
"Information": [
{
},
{
"Languages": null
},
{
"Legal hold": "false"
},
{
},
{
"Date Received": "2023-01-30 10:27:58.090"
},
{
"Date sent": "2023-01-30 12:27:53.000"
},
{
"Date Created": "2023-01-30 12:27:53.000"
},
{
"Retention Date": "2023-07-31 12:27:53.000"
},
{
"Ecomm Date": "2023-01-30 12:27:53.000"
},
{
},
{
},
{
},
{
},
{
},
{
"Message Id": "<643565394.0.1675074473937.JavaMail.alitaha@ip-192-168-31-20.eu-west-1.compute.internal>"
},
{
},
{
},
{
},
{
},
{
},
{
"Unique ID": "6BF42EAC97D5C20A071D34AB7BCE7B8C"
}
],
"Attachments": [
{
"Attachments": [
{
"parent": null,
"isPasswordProtected": "false",
"sha256": "60984071781d33399dd72ebbd3e06b9e481ec4cd1d89ef38218fc1653732df",
"fileSize": "6122",
"archiveFilename": "/7_2023-01-30_10-30-29.444/Tasks/27/attachments/488E00680FF11FFED143409A9F7575B5-Automationtest.docx",
"fileContent": "Automation test"
}
]
}
],
"primaryLanguage": "English"
}
以下是相关的POJOS文件:
@Getter
@Setter
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class OriginalDTO {
@SerializedName("Attachments")
private List<Attachment> attachments;
@SerializedName("BccRecipients")
private List<BccRecipient> bccRecipients;
@SerializedName("CcRecipients")
private List<CcRecipient> ccRecipients;
@SerializedName("Content")
private List<Content> content;
@SerializedName("FromRecipients")
private List<FromRecipient> fromRecipients;
@SerializedName("Generic")
private List<Generic> generic;
@SerializedName("Information")
private List<Information> information;
@SerializedName("Messages")
private List<Message> messages;
@SerializedName("Participants")
private List<Participant> participants;
@SerializedName("Product")
private List<Product> product;
@SerializedName("ToRecipients")
private List<ToRecipient> toRecipients;
@SerializedName("transcribedMessages")
private List<TranscribedMessage> transcribedMessages;
}
@Getter
@Setter
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class OriginalDTO {
@SerializedName("Attachments")
private List<Attachment> attachments;
@SerializedName("BccRecipients")
private List<BccRecipient> bccRecipients;
@SerializedName("CcRecipients")
private List<CcRecipient> ccRecipients;
@SerializedName("Content")
private List<Content> content;
@SerializedName("FromRecipients")
private List<FromRecipient> fromRecipients;
@SerializedName("Generic")
private List<Generic> generic;
@SerializedName("Information")
private List<Information> information;
@SerializedName("Messages")
private List<Message> messages;
@SerializedName("Participants")
private List<Participant> participants;
@SerializedName("Product")
private List<Product> product;
@SerializedName("ToRecipients")
private List<ToRecipient> toRecipients;
@SerializedName("transcribedMessages")
private List<TranscribedMessage> transcribedMessages;
}
@Getter
@Setter
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class Attachment {
@SerializedName("archiveFilename")
private String archiveFilename;
@SerializedName("Attachments")
private List<Attachment> attachments;
@SerializedName("fileContent")
private String fileContent;
@SerializedName("fileSize")
private String fileSize;
@SerializedName("isPasswordProtected")
private String isPasswordProtected;
@SerializedName("parent")
private String parent;
@SerializedName("sha256")
private String sha256;
}
继续,为了创建java对象,我用了下面的代码:
OriginalDTO original = response.then().statusCode(200).extract().as(OriginalDTO.class);
但由于某种原因,所有OriginalDTO字段值都为空。我需要在此代码中修复的是
1条答案
按热度按时间gudnpqoy1#
我用变通方法处理了这个问题
代替
x1个月1个月)