@Test public void testExecutionContextSheet() throws Exception { context.setProperty(SHEET_PROPERTY, "Code.Sheet"); final DocumentReference sheetReference = new DocumentReference(WIKI_NAME, "Code", "Sheet"); getMockery().checking(new Expectations() { { oneOf(documentAccessBridge).getCurrentDocumentReference(); will(returnValue(document.getDocumentReference())); oneOf(documentAccessBridge).exists(sheetReference); will(returnValue(true)); oneOf(documentAccessBridge).getProperty(sheetReference, SHEET_CLASS_REFERENCE, ACTION_PROPERTY); will(returnValue("")); } }); Assert.assertEquals(Arrays.asList(sheetReference), getMockedComponent().getSheets(document, "view")); getMockery().checking(new Expectations() { { oneOf(documentAccessBridge).getCurrentDocumentReference(); will(returnValue(null)); oneOf(documentSheetBinder).getSheets(document); will(returnValue(Collections.emptyList())); oneOf(modelBridge).getXObjectClassReferences(document); will(returnValue(Collections.emptySet())); } }); Assert.assertTrue(getMockedComponent().getSheets(document, "edit").isEmpty()); context.removeProperty(SHEET_PROPERTY); getMockery().checking(new Expectations() { { oneOf(documentSheetBinder).getSheets(document); will(returnValue(Collections.emptyList())); oneOf(modelBridge).getXObjectClassReferences(document); will(returnValue(Collections.emptySet())); } }); Assert.assertTrue(getMockedComponent().getSheets(document, "get").isEmpty()); }
@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();  }