@Test public void testSheetResolutionSequence() throws Exception { final String contextSheetName = "ContextSheet"; context.setProperty(SHEET_PROPERTY, contextSheetName); final DocumentReference documentSheetReference = new DocumentReference(WIKI_NAME, "ABC", "DocumentSheet"); final DocumentReference classSheetReference = new DocumentReference(WIKI_NAME, "BlogCode", "BlogPostSheet"); final DocumentReference classReference = new DocumentReference(WIKI_NAME, "Blog", "BlogPostClass"); final DocumentModelBridge classDocument = getMockery().mock(DocumentModelBridge.class, "xclass"); final String currentAction = "foo"; final Sequence sheetResolutionSequence = getMockery().sequence("sheetResolutionSequence"); getMockery().checking(new Expectations() { { oneOf(documentAccessBridge).getCurrentDocumentReference(); inSequence(sheetResolutionSequence); will(returnValue(document.getDocumentReference())); oneOf(documentAccessBridge).exists( new DocumentReference(document.getDocumentReference().getWikiReference().getName(), document .getDocumentReference().getLastSpaceReference().getName(), contextSheetName)); inSequence(sheetResolutionSequence); will(returnValue(false)); oneOf(documentSheetBinder).getSheets(document); inSequence(sheetResolutionSequence); will(returnValue(Collections.singletonList(documentSheetReference))); oneOf(documentAccessBridge).exists(documentSheetReference); inSequence(sheetResolutionSequence); will(returnValue(true)); oneOf(documentAccessBridge).getProperty(documentSheetReference, SHEET_CLASS_REFERENCE, ACTION_PROPERTY); inSequence(sheetResolutionSequence); will(returnValue("bar")); oneOf(modelBridge).getXObjectClassReferences(document); inSequence(sheetResolutionSequence); will(returnValue(Collections.singleton(classReference))); oneOf(documentAccessBridge).getTranslatedDocumentInstance(classReference); inSequence(sheetResolutionSequence); will(returnValue(classDocument)); oneOf(classSheetBinder).getSheets(classDocument); inSequence(sheetResolutionSequence); will(returnValue(Collections.singletonList(classSheetReference))); oneOf(documentAccessBridge).exists(classSheetReference); inSequence(sheetResolutionSequence); will(returnValue(true)); oneOf(documentAccessBridge).getProperty(classSheetReference, SHEET_CLASS_REFERENCE, ACTION_PROPERTY); inSequence(sheetResolutionSequence); will(returnValue(currentAction)); } }); getMockedComponent().getSheets(document, currentAction); }
@Override public List<DocumentReference> getSheets(DocumentModelBridge document, String action) { DocumentReference documentReference = document.getDocumentReference(); String sheetStringRef = getContextSheet(); if (sheetStringRef != null && documentReference.equals(documentAccessBridge.getCurrentDocumentReference())) { DocumentReference sheetReference = documentReferenceResolver.resolve(sheetStringRef, documentReference); if (matchSheet(sheetReference, action)) { return Collections.singletonList(sheetReference); } } List<DocumentReference> sheets = getDocumentSheets(document, action); if (sheets.isEmpty()) { sheets = new ArrayList<DocumentReference>(); for (DocumentReference classReference : modelBridge.getXObjectClassReferences(document)) { sheets.addAll(getClassSheets(classReference, action)); } } return sheets; }
DefaultSheetManager implements SheetManager { @Override public List<DocumentReference> getSheets(DocumentModelBridge document, String action) { DocumentReference documentReference = document.getDocumentReference(); String sheetStringRef = getContextSheet(); if (sheetStringRef != null && documentReference.equals(documentAccessBridge.getCurrentDocumentReference())) { DocumentReference sheetReference = documentReferenceResolver.resolve(sheetStringRef, documentReference); if (matchSheet(sheetReference, action)) { return Collections.singletonList(sheetReference); } } List<DocumentReference> sheets = getDocumentSheets(document, action); if (sheets.isEmpty()) { sheets = new ArrayList<DocumentReference>(); for (DocumentReference classReference : modelBridge.getXObjectClassReferences(document)) { sheets.addAll(getClassSheets(classReference, action)); } } return sheets; } }
DefaultSheetManager implements SheetManager { @Override public List<DocumentReference> getSheets(DocumentModelBridge document, String action) { DocumentReference documentReference = document.getDocumentReference(); String sheetStringRef = getContextSheet(); if (sheetStringRef != null && documentReference.equals(documentAccessBridge.getCurrentDocumentReference())) { DocumentReference sheetReference = documentReferenceResolver.resolve(sheetStringRef, documentReference); if (matchSheet(sheetReference, action)) { return Collections.singletonList(sheetReference); } } List<DocumentReference> sheets = getDocumentSheets(document, action); if (sheets.isEmpty()) { sheets = new ArrayList<DocumentReference>(); for (DocumentReference classReference : modelBridge.getXObjectClassReferences(document)) { sheets.addAll(getClassSheets(classReference, action)); } } return sheets; }  }
DefaultSheetManager implements SheetManager { @Override public List<DocumentReference> getSheets(DocumentModelBridge document, String action) { DocumentReference documentReference = document.getDocumentReference(); String sheetStringRef = getContextSheet(); if (sheetStringRef != null && documentReference.equals(documentAccessBridge.getCurrentDocumentReference())) { DocumentReference sheetReference = documentReferenceResolver.resolve(sheetStringRef, documentReference); if (matchSheet(sheetReference, action)) { return Collections.singletonList(sheetReference); } } List<DocumentReference> sheets = getDocumentSheets(document, action); if (sheets.isEmpty()) { sheets = new ArrayList<DocumentReference>(); for (DocumentReference classReference : modelBridge.getXObjectClassReferences(document)) { sheets.addAll(getClassSheets(classReference, action)); } } return sheets; }  @Override List<DocumentReference> getSheets(DocumentModelBridge document, String action); @Override boolean isSheetForced(); }
DefaultSheetManager implements SheetManager { @Override public List<DocumentReference> getSheets(DocumentModelBridge document, String action) { DocumentReference documentReference = document.getDocumentReference(); String sheetStringRef = getContextSheet(); if (sheetStringRef != null && documentReference.equals(documentAccessBridge.getCurrentDocumentReference())) { DocumentReference sheetReference = documentReferenceResolver.resolve(sheetStringRef, documentReference); if (matchSheet(sheetReference, action)) { return Collections.singletonList(sheetReference); } } List<DocumentReference> sheets = getDocumentSheets(document, action); if (sheets.isEmpty()) { sheets = new ArrayList<DocumentReference>(); for (DocumentReference classReference : modelBridge.getXObjectClassReferences(document)) { sheets.addAll(getClassSheets(classReference, action)); } } return sheets; }  @Override List<DocumentReference> getSheets(DocumentModelBridge document, String action); @Override boolean isSheetForced();  }