### Question:
DefaultSignatureStore implements SignatureStore { @Override public byte[] retrieve(EntityReference entity) throws SignatureStoreException { checkArguments(entity); DocumentReference docRef = this.resolver.resolve(entity); XWikiContext context = this.contextProvider.get(); try { XWikiDocument document = context.getWiki().getDocument(docRef, context); DocumentReference signatureClass = new DocumentReference(SIGNATURECLASS, docRef.getWikiReference()); String entityReference = entity.getName(); BaseObject object = document.getXObject(signatureClass, SIGNATURECLASS_PROP_REFERENCE, entityReference); if (object == null) { return null; } String signature = object.getLargeStringValue(SIGNATURECLASS_PROP_SIGNATURE); if (signature == null) { return null; } return this.base64.decode(signature); } catch (XWikiException e) { throw new SignatureStoreException("Error while retrieving signature for entity [" + entity + "]", e); } catch (IOException e) { throw new SignatureStoreException("Error while decoding signature for entity [" + entity + "]", e); } }  @Override void store(EntityReference entity, byte[] signature); @Override byte[] retrieve(EntityReference entity); static final LocalDocumentReference SIGNATURECLASS; static final String SIGNATURECLASS_PROP_REFERENCE; static final String SIGNATURECLASS_PROP_SIGNATURE; }### Answer:
@Test public void testRetrievingExistingSignature() throws Exception { XWikiDocument sourceDocument = mock(XWikiDocument.class); when(this.xwiki.getDocument(new DocumentReference("wiki", "space", "document"), this.xcontext)) .thenReturn(sourceDocument); BaseObject signatureObject = mock(BaseObject.class); when(sourceDocument.getXObject( new DocumentReference(DefaultSignatureStore.SIGNATURECLASS, new WikiReference("wiki")), DefaultSignatureStore.SIGNATURECLASS_PROP_REFERENCE, "block")).thenReturn(signatureObject); when(signatureObject.getLargeStringValue(DefaultSignatureStore.SIGNATURECLASS_PROP_SIGNATURE)).thenReturn( ENCODED_SIGNATURE); assertThat( this.store.retrieve(new BlockReference("block", new DocumentReference("wiki", "space", "document"))), equalTo(SIGNATURE)); }
@Test public void testRetrievingMissingSignature() throws Exception { XWikiDocument sourceDocument = mock(XWikiDocument.class); when(this.xwiki.getDocument(new DocumentReference("wiki", "space", "document"), this.xcontext)) .thenReturn(sourceDocument); assertThat( this.store.retrieve(new BlockReference("block", new DocumentReference("wiki", "space", "document"))), nullValue()); verify(sourceDocument).getXObject( new DocumentReference(DefaultSignatureStore.SIGNATURECLASS, new WikiReference("wiki")), DefaultSignatureStore.SIGNATURECLASS_PROP_REFERENCE, "block"); }