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 @@
/*
- * Copyright (c) 2010-2015, Isode Limited, London, England.
+ * Copyright (c) 2010-2016, Isode Limited, London, England.
* All rights reserved.
*/
package com.isode.stroke.vcards;
@@ -82,14 +82,15 @@ public class VCardManager {
requestVCard(new JID());
}
-
private void handleVCardReceived(final JID actualJID, VCard vcard, ErrorPayload error) {
- if (error != null || vcard == null) {
- vcard = new VCard();
+ if (error == null) {
+ if (vcard == null) {
+ vcard = new VCard();
+ }
+ requestedVCards.remove(actualJID);
+ JID jid = actualJID.isValid() ? actualJID : ownJID.toBare();
+ setVCard(jid, vcard);
}
- requestedVCards.remove(actualJID);
- JID jid = actualJID.isValid() ? actualJID : ownJID.toBare();
- setVCard(jid, vcard);
}
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 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -155,14 +155,12 @@ public class VCardManagerTest {
@Test
public void testRequest_Error() {
- VCardManager testling = createManager();
- testling.requestVCard(new JID("foo@bar.com/baz"));
- stanzaChannel.onIQReceived.emit(IQ.createError(new JID("baz@fum.com/foo"), stanzaChannel.sentStanzas.get(0).getTo(), stanzaChannel.sentStanzas.get(0).getID()));
+ VCardManager testling = createManager();
+ testling.requestVCard(new JID("foo@bar.com/baz"));
+ stanzaChannel.onIQReceived.emit(IQ.createError(new JID("baz@fum.com/foo"), stanzaChannel.sentStanzas.get(0).getTo(), stanzaChannel.sentStanzas.get(0).getID()));
- assertEquals(1, (changes.size()));
- assertEquals(new JID("foo@bar.com/baz"), changes.get(0).jid);
- assertEquals((""), changes.get(0).vcard.getFullName());
- assertEquals((""), vcardStorage.getVCard(new JID("foo@bar.com/baz")).getFullName());
+ // On error, cached vCards should not be changed
+ assertEquals(0,changes.size());
}
@Test