@Test public void resolveWhenNoBlockPassed() throws Exception { try { mocker.getComponentUnderTest().resolve("something", EntityType.DOCUMENT); Assert.fail("Should have thrown an IllegalArgumentException here"); } catch (IllegalArgumentException expected) { Assert.assertEquals("You must pass one parameter of type [org.xwiki.rendering.block.Block]", expected.getMessage()); } }
@Override public EntityReference resolve(String representation, EntityType entityType, Object... parameters) { if (parameters.length != 1 || !(parameters[0] instanceof Block)) { throw new IllegalArgumentException(String.format("You must pass one parameter of type [%s]", Block.class.getName())); } Block currentBlock = (Block) parameters[0]; EntityReference result; MetaDataBlock metaDataBlock = currentBlock.getFirstBlock(new MetadataBlockMatcher(MetaData.BASE), Block.Axes.ANCESTOR); if (metaDataBlock == null) { result = this.currentEntityReferenceResolver.resolve(representation, entityType); } else { String sourceMetaData = (String) metaDataBlock.getMetaData().getMetaData(MetaData.BASE); result = this.currentEntityReferenceResolver.resolve(representation, entityType, this.currentEntityReferenceResolver.resolve(sourceMetaData, EntityType.DOCUMENT)); } return result; }
CurrentMacroEntityReferenceResolver implements EntityReferenceResolver<String> { @Override public EntityReference resolve(String representation, EntityType entityType, Object... parameters) { if (parameters.length != 1 || !(parameters[0] instanceof Block)) { throw new IllegalArgumentException(String.format("You must pass one parameter of type [%s]", Block.class.getName())); } Block currentBlock = (Block) parameters[0]; EntityReference result; MetaDataBlock metaDataBlock = currentBlock.getFirstBlock(new MetadataBlockMatcher(MetaData.BASE), Block.Axes.ANCESTOR); if (metaDataBlock == null) { result = this.currentEntityReferenceResolver.resolve(representation, entityType); } else { String sourceMetaData = (String) metaDataBlock.getMetaData().getMetaData(MetaData.BASE); result = this.currentEntityReferenceResolver.resolve(representation, entityType, this.currentEntityReferenceResolver.resolve(sourceMetaData, EntityType.DOCUMENT)); } return result; } }
CurrentMacroEntityReferenceResolver implements EntityReferenceResolver<String> { @Override public EntityReference resolve(String representation, EntityType entityType, Object... parameters) { if (parameters.length != 1 || !(parameters[0] instanceof Block)) { throw new IllegalArgumentException(String.format("You must pass one parameter of type [%s]", Block.class.getName())); } Block currentBlock = (Block) parameters[0]; EntityReference result; MetaDataBlock metaDataBlock = currentBlock.getFirstBlock(new MetadataBlockMatcher(MetaData.BASE), Block.Axes.ANCESTOR); if (metaDataBlock == null) { result = this.currentEntityReferenceResolver.resolve(representation, entityType); } else { String sourceMetaData = (String) metaDataBlock.getMetaData().getMetaData(MetaData.BASE); result = this.currentEntityReferenceResolver.resolve(representation, entityType, this.currentEntityReferenceResolver.resolve(sourceMetaData, EntityType.DOCUMENT)); } return result; }  }
CurrentMacroEntityReferenceResolver implements EntityReferenceResolver<String> { @Override public EntityReference resolve(String representation, EntityType entityType, Object... parameters) { if (parameters.length != 1 || !(parameters[0] instanceof Block)) { throw new IllegalArgumentException(String.format("You must pass one parameter of type [%s]", Block.class.getName())); } Block currentBlock = (Block) parameters[0]; EntityReference result; MetaDataBlock metaDataBlock = currentBlock.getFirstBlock(new MetadataBlockMatcher(MetaData.BASE), Block.Axes.ANCESTOR); if (metaDataBlock == null) { result = this.currentEntityReferenceResolver.resolve(representation, entityType); } else { String sourceMetaData = (String) metaDataBlock.getMetaData().getMetaData(MetaData.BASE); result = this.currentEntityReferenceResolver.resolve(representation, entityType, this.currentEntityReferenceResolver.resolve(sourceMetaData, EntityType.DOCUMENT)); } return result; }  @Override EntityReference resolve(String representation, EntityType entityType, Object... parameters); }
CurrentMacroEntityReferenceResolver implements EntityReferenceResolver<String> { @Override public EntityReference resolve(String representation, EntityType entityType, Object... parameters) { if (parameters.length != 1 || !(parameters[0] instanceof Block)) { throw new IllegalArgumentException(String.format("You must pass one parameter of type [%s]", Block.class.getName())); } Block currentBlock = (Block) parameters[0]; EntityReference result; MetaDataBlock metaDataBlock = currentBlock.getFirstBlock(new MetadataBlockMatcher(MetaData.BASE), Block.Axes.ANCESTOR); if (metaDataBlock == null) { result = this.currentEntityReferenceResolver.resolve(representation, entityType); } else { String sourceMetaData = (String) metaDataBlock.getMetaData().getMetaData(MetaData.BASE); result = this.currentEntityReferenceResolver.resolve(representation, entityType, this.currentEntityReferenceResolver.resolve(sourceMetaData, EntityType.DOCUMENT)); } return result; }  @Override EntityReference resolve(String representation, EntityType entityType, Object... parameters);  }