ich die HashMap zu behaupten, ich versuche, das von dem Verfahren getPaymentMethod() mit dem HashMap erwartet.Assert zwei HashMaps mit Assertionsfehler versagt
public void testGetPaymentMethod() throws Exception {
List<Map<String, Object>> paymentOptionsList = new ArrayList<Map<String, Object>>();
Map<String, Object> pO = new HashMap<String, Object>();
Map<String, Object> pM = new HashMap<String, Object>();
Map<String, Object> capam = new HashMap<String, Object>();
Map<String, Object> preAuthDetail = new HashMap<String, Object>();
preAuthDetail.put("sourceSystem", "ABCD");
preAuthDetail.put("sourceLocation", "EFGH");
preAuthDetail.put("authorizationCode", "OL_DF161216J34491");
capam.put("paymentAmount", 850);
capam.put("preAuthDetail", preAuthDetail);
pM.put("capam", capam);
pO.put("pM",pM);
paymentOptionsList.add(pO);
@SuppressWarnings("unchecked")
HashMap<String, Object> result = (HashMap<String, Object>) myTransformation.getPaymentMethod(paymentOptionsList,null);
Map<String, Object> expected = new HashMap<String, Object>();
Map<String, Object> preAuthorizationProfile = new HashMap<String, Object>();
Map<String, Object> source = new HashMap<String, Object>();
Map<String, Object> amount = new HashMap<String, Object>();
source.put("sourceSystem", "ABCD");
source.put("sourceLocation", "EFGH");
amount.put("amount", 850);
amount.put("monetaryAmount", "UNITEDSTATES_DOLLAR");
preAuthorizationProfile.put("source", source);
preAuthorizationProfile.put("preAuthorizationId", "OL_DF161216J34491");
preAuthorizationProfile.put("amount", amount);
pM.clear();
pM.put("preAuthorizationProfile", preAuthorizationProfile);
expected.put("pM", pM);
assertThat(result,is(expected));
}
Aber ich bin immer Assertion Fehler wie
folgtErwartet: < ist {payment = {preAuthorizationProfile = {amount = {amount = 850, MonetaryAmount = UNITEDSTATES_DOLLAR} source = {sourceSystem = ABCD , Quelle Location = EFGH}, preAuthorizationId = OL_DF161216J34491}}}> aber: war < {payment = {preAuthorizationProfile = {source = {sourceSystem = ABCD, Sourcelocation = EFGH}}, preAuthorizationId = OL_DF161216J34491, eine Mount = {amount = 850, monetaryAmount = UNITEDSTATES_DOLLAR}}}>
Der erwartete hat einen Schlüssel namens 'Betrag', während der tatsächliche hat einen Schlüssel von' a mount' (beachten Sie das Leerzeichen). –
@JoeC Ich denke, ich habe es von der Eingabeaufforderung cmd kopiert, weshalb es ein Leerzeichen zeigt. – Beginner