Search in sources :

Example 1 with BlockReferenceResolver

use of org.xwiki.model.reference.BlockReferenceResolver in project xwiki-platform by xwiki.

the class SignableMacroTest method setUp.

@Before
public void setUp() throws Exception {
    BeanManager beanManager = mocker.getInstance(BeanManager.class);
    when(beanManager.getBeanDescriptor(Object.class)).thenReturn(new DefaultBeanDescriptor(Object.class));
    store = mocker.registerMockComponent(SignatureStore.class);
    when(store.retrieve(BLOCK_REFERENCE)).thenReturn(SIGNATURE);
    BlockSignatureGenerator signer = mocker.registerMockComponent(BlockSignatureGenerator.class, "macro");
    when(signer.generate(BLOCK, PARAMETERS)).thenReturn(SIGNATURE);
    BlockSignatureVerifier verifier = mocker.registerMockComponent(BlockSignatureVerifier.class, "macro");
    when(verifier.verify(SIGNATURE, BLOCK, null)).thenReturn(VERIFIED);
    BlockReferenceResolver<Block> resolver = mocker.registerMockComponent(new DefaultParameterizedType(null, BlockReferenceResolver.class, Block.class), "currentsignedmacro");
    when(resolver.resolve(BLOCK)).thenReturn(BLOCK_REFERENCE);
    macro = mocker.getComponentUnderTest();
}
Also used : SignatureStore(org.xwiki.crypto.store.SignatureStore) BlockSignatureGenerator(org.xwiki.rendering.signature.BlockSignatureGenerator) DefaultBeanDescriptor(org.xwiki.properties.internal.DefaultBeanDescriptor) Block(org.xwiki.rendering.block.Block) MacroBlock(org.xwiki.rendering.block.MacroBlock) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) BeanManager(org.xwiki.properties.BeanManager) BlockSignatureVerifier(org.xwiki.rendering.signature.BlockSignatureVerifier) BlockReferenceResolver(org.xwiki.model.reference.BlockReferenceResolver) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 SignatureStore (org.xwiki.crypto.store.SignatureStore)1 BlockReferenceResolver (org.xwiki.model.reference.BlockReferenceResolver)1 BeanManager (org.xwiki.properties.BeanManager)1 DefaultBeanDescriptor (org.xwiki.properties.internal.DefaultBeanDescriptor)1 Block (org.xwiki.rendering.block.Block)1 MacroBlock (org.xwiki.rendering.block.MacroBlock)1 BlockSignatureGenerator (org.xwiki.rendering.signature.BlockSignatureGenerator)1 BlockSignatureVerifier (org.xwiki.rendering.signature.BlockSignatureVerifier)1