@Test public void getAssetRenditionGroups() { ctx.currentResource("/content/download_with_asset_rendition_groups"); final Options group1Options = new TestOptionsImpl(ctx.currentResource().getChild("asset-renditions-groups/items/item0/asset-renditions/items")); final Options group2Options = new TestOptionsImpl(ctx.currentResource().getChild("asset-renditions-groups/items/item1/asset-renditions/items")); doReturn(group1Options).when(modelFactory).getModelFromWrappedRequest(eq(ctx.request()), argThat(new IsSameResourceByPath(ctx.currentResource().getChild("asset-renditions-groups/items/item0/asset-renditions").getPath())), eq(Options.class)); doReturn(group2Options).when(modelFactory).getModelFromWrappedRequest(eq(ctx.request()), argThat(new IsSameResourceByPath(ctx.currentResource().getChild("asset-renditions-groups/items/item1/asset-renditions").getPath())), eq(Options.class)); final Download download = ctx.request().adaptTo(Download.class); final List<Download.AssetRenditionsGroup> actual = download.getAssetRenditionsGroups(); assertEquals(2, actual.size()); assertEquals("Group 1", actual.get(0).getTitle()); assertEquals("Rendition 1.1", actual.get(0).getItems().get(0).getText()); assertEquals("rendition-1-1", actual.get(0).getItems().get(0).getValue()); assertEquals("Rendition 1.2", actual.get(0).getItems().get(1).getText()); assertEquals("rendition-1-2", actual.get(0).getItems().get(1).getValue()); assertEquals(2, actual.size()); assertEquals("Group 2", actual.get(1).getTitle()); assertEquals("Rendition 2.1", actual.get(1).getItems().get(0).getText()); assertEquals("rendition-2-1", actual.get(1).getItems().get(0).getValue()); assertEquals("Rendition 2.2", actual.get(1).getItems().get(1).getText()); assertEquals("rendition-2-2", actual.get(1).getItems().get(1).getValue()); }
@Override public List<AssetRenditionsGroup> getAssetRenditionsGroups() { if (assetRenditionsGroups == null) { assetRenditionsGroups = new ArrayList<>(); final Resource groups = request.getResource().getChild(NN_ASSET_RENDITIONS_GROUPS + "/" + NN_ITEMS); if (groups != null) { for (Resource group : groups.getChildren()) { group = group.getChild(NN_ASSET_RENDITIONS); if (group != null) { final String title = group.getParent().getValueMap().get(PN_ASSET_RENDITIONS_GROUP_TITLE, String.class); final Options options = modelFactory.getModelFromWrappedRequest(request, group, Options.class); if (options != null) { assetRenditionsGroups.add(new AssetRenditionsGroup(title, options)); } } } } } return Collections.unmodifiableList(assetRenditionsGroups); }
DownloadImpl implements Download, ComponentExporter { @Override public List<AssetRenditionsGroup> getAssetRenditionsGroups() { if (assetRenditionsGroups == null) { assetRenditionsGroups = new ArrayList<>(); final Resource groups = request.getResource().getChild(NN_ASSET_RENDITIONS_GROUPS + "/" + NN_ITEMS); if (groups != null) { for (Resource group : groups.getChildren()) { group = group.getChild(NN_ASSET_RENDITIONS); if (group != null) { final String title = group.getParent().getValueMap().get(PN_ASSET_RENDITIONS_GROUP_TITLE, String.class); final Options options = modelFactory.getModelFromWrappedRequest(request, group, Options.class); if (options != null) { assetRenditionsGroups.add(new AssetRenditionsGroup(title, options)); } } } } } return Collections.unmodifiableList(assetRenditionsGroups); } }
DownloadImpl implements Download, ComponentExporter { @Override public List<AssetRenditionsGroup> getAssetRenditionsGroups() { if (assetRenditionsGroups == null) { assetRenditionsGroups = new ArrayList<>(); final Resource groups = request.getResource().getChild(NN_ASSET_RENDITIONS_GROUPS + "/" + NN_ITEMS); if (groups != null) { for (Resource group : groups.getChildren()) { group = group.getChild(NN_ASSET_RENDITIONS); if (group != null) { final String title = group.getParent().getValueMap().get(PN_ASSET_RENDITIONS_GROUP_TITLE, String.class); final Options options = modelFactory.getModelFromWrappedRequest(request, group, Options.class); if (options != null) { assetRenditionsGroups.add(new AssetRenditionsGroup(title, options)); } } } } } return Collections.unmodifiableList(assetRenditionsGroups); }  }
DownloadImpl implements Download, ComponentExporter { @Override public List<AssetRenditionsGroup> getAssetRenditionsGroups() { if (assetRenditionsGroups == null) { assetRenditionsGroups = new ArrayList<>(); final Resource groups = request.getResource().getChild(NN_ASSET_RENDITIONS_GROUPS + "/" + NN_ITEMS); if (groups != null) { for (Resource group : groups.getChildren()) { group = group.getChild(NN_ASSET_RENDITIONS); if (group != null) { final String title = group.getParent().getValueMap().get(PN_ASSET_RENDITIONS_GROUP_TITLE, String.class); final Options options = modelFactory.getModelFromWrappedRequest(request, group, Options.class); if (options != null) { assetRenditionsGroups.add(new AssetRenditionsGroup(title, options)); } } } } } return Collections.unmodifiableList(assetRenditionsGroups); }  @Override List<AssetRenditionsGroup> getAssetRenditionsGroups(); Collection<AssetModel> getAssets(); String getZipFileName(); @Override long getMaxContentSize(); @Override long getDownloadContentSize(); @Override String getMaxContentSizeLabel(); @Override String getDownloadContentSizeLabel(); @Nonnull @Override String getExportedType(); }
DownloadImpl implements Download, ComponentExporter { @Override public List<AssetRenditionsGroup> getAssetRenditionsGroups() { if (assetRenditionsGroups == null) { assetRenditionsGroups = new ArrayList<>(); final Resource groups = request.getResource().getChild(NN_ASSET_RENDITIONS_GROUPS + "/" + NN_ITEMS); if (groups != null) { for (Resource group : groups.getChildren()) { group = group.getChild(NN_ASSET_RENDITIONS); if (group != null) { final String title = group.getParent().getValueMap().get(PN_ASSET_RENDITIONS_GROUP_TITLE, String.class); final Options options = modelFactory.getModelFromWrappedRequest(request, group, Options.class); if (options != null) { assetRenditionsGroups.add(new AssetRenditionsGroup(title, options)); } } } } } return Collections.unmodifiableList(assetRenditionsGroups); }  @Override List<AssetRenditionsGroup> getAssetRenditionsGroups(); Collection<AssetModel> getAssets(); String getZipFileName(); @Override long getMaxContentSize(); @Override long getDownloadContentSize(); @Override String getMaxContentSizeLabel(); @Override String getDownloadContentSizeLabel(); @Nonnull @Override String getExportedType(); static final String PN_ASSET_RENDITIONS_GROUP_TITLE; static final String NN_ASSET_RENDITIONS; static final String NN_ITEMS; }