summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/isode/stroke/vcards/VCardManager.java15
-rw-r--r--test/com/isode/stroke/vcards/VCardManagerTest.java14
2 files changed, 14 insertions, 15 deletions
diff --git a/src/com/isode/stroke/vcards/VCardManager.java b/src/com/isode/stroke/vcards/VCardManager.java
index 80e7942..082aeeb 100644
--- a/src/com/isode/stroke/vcards/VCardManager.java
+++ b/src/com/isode/stroke/vcards/VCardManager.java
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2015, Isode Limited, London, England. 2 * Copyright (c) 2010-2016, Isode Limited, London, England.
3 * All rights reserved. 3 * All rights reserved.
4 */ 4 */
5package com.isode.stroke.vcards; 5package com.isode.stroke.vcards;
@@ -82,14 +82,15 @@ public class VCardManager {
82 requestVCard(new JID()); 82 requestVCard(new JID());
83 } 83 }
84 84
85
86 private void handleVCardReceived(final JID actualJID, VCard vcard, ErrorPayload error) { 85 private void handleVCardReceived(final JID actualJID, VCard vcard, ErrorPayload error) {
87 if (error != null || vcard == null) { 86 if (error == null) {
88 vcard = new VCard(); 87 if (vcard == null) {
88 vcard = new VCard();
89 }
90 requestedVCards.remove(actualJID);
91 JID jid = actualJID.isValid() ? actualJID : ownJID.toBare();
92 setVCard(jid, vcard);
89 } 93 }
90 requestedVCards.remove(actualJID);
91 JID jid = actualJID.isValid() ? actualJID : ownJID.toBare();
92 setVCard(jid, vcard);
93 } 94 }
94 95
95 public SetVCardRequest createSetVCardRequest(final VCard vcard) { 96 public SetVCardRequest createSetVCardRequest(final VCard vcard) {
diff --git a/test/com/isode/stroke/vcards/VCardManagerTest.java b/test/com/isode/stroke/vcards/VCardManagerTest.java
index 4c51081..729eda9 100644
--- a/test/com/isode/stroke/vcards/VCardManagerTest.java
+++ b/test/com/isode/stroke/vcards/VCardManagerTest.java
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2013 Isode Limited. 2 * Copyright (c) 2010-2016 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -155,14 +155,12 @@ public class VCardManagerTest {
155 155
156 @Test 156 @Test
157 public void testRequest_Error() { 157 public void testRequest_Error() {
158 VCardManager testling = createManager(); 158 VCardManager testling = createManager();
159 testling.requestVCard(new JID("foo@bar.com/baz")); 159 testling.requestVCard(new JID("foo@bar.com/baz"));
160 stanzaChannel.onIQReceived.emit(IQ.createError(new JID("baz@fum.com/foo"), stanzaChannel.sentStanzas.get(0).getTo(), stanzaChannel.sentStanzas.get(0).getID())); 160 stanzaChannel.onIQReceived.emit(IQ.createError(new JID("baz@fum.com/foo"), stanzaChannel.sentStanzas.get(0).getTo(), stanzaChannel.sentStanzas.get(0).getID()));
161 161
162 assertEquals(1, (changes.size())); 162 // On error, cached vCards should not be changed
163 assertEquals(new JID("foo@bar.com/baz"), changes.get(0).jid); 163 assertEquals(0,changes.size());
164 assertEquals((""), changes.get(0).vcard.getFullName());
165 assertEquals((""), vcardStorage.getVCard(new JID("foo@bar.com/baz")).getFullName());
166 } 164 }
167 165
168 @Test 166 @Test