@Test public void testDocument2FlatValue() { Document doc = spy(new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date())); Map result = new HashMap(); result.put(DocumentFieldValueMarshaller.SERVER_TEMPLATE_ID, SERVER_TEMPLATE_ID); when(context.getAttributes()).thenReturn(result); marshaller.init(doc, field, form, context); DocumentData documentData = marshaller.toFlatValue(); verify(doc, never()).getLink(); assertNotNull(documentData); assertEquals(doc.getName(), documentData.getFileName()); assertEquals(doc.getSize(), documentData.getSize()); assertEquals(EXPECTED_DOWNLOAD_LINK, documentData.getLink()); }
@Override public DocumentData toFlatValue() { if (originalValue == null) { return null; } String templateId = (String) context.getAttributes().get(SERVER_TEMPLATE_ID); return fromDocument(originalValue, templateId); }
DocumentFieldValueMarshaller extends AbstractFieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition> { @Override public DocumentData toFlatValue() { if (originalValue == null) { return null; } String templateId = (String) context.getAttributes().get(SERVER_TEMPLATE_ID); return fromDocument(originalValue, templateId); } }
DocumentFieldValueMarshaller extends AbstractFieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition> { @Override public DocumentData toFlatValue() { if (originalValue == null) { return null; } String templateId = (String) context.getAttributes().get(SERVER_TEMPLATE_ID); return fromDocument(originalValue, templateId); } @Inject  DocumentFieldValueMarshaller(UploadedDocumentStorage documentStorage); }
DocumentFieldValueMarshaller extends AbstractFieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition> { @Override public DocumentData toFlatValue() { if (originalValue == null) { return null; } String templateId = (String) context.getAttributes().get(SERVER_TEMPLATE_ID); return fromDocument(originalValue, templateId); } @Inject  DocumentFieldValueMarshaller(UploadedDocumentStorage documentStorage); @Override Class<DocumentFieldDefinition> getSupportedField(); @Override Supplier<FieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition>> newInstanceSupplier(); @Override DocumentData toFlatValue(); @Override Document toRawValue(DocumentData documentData); }
DocumentFieldValueMarshaller extends AbstractFieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition> { @Override public DocumentData toFlatValue() { if (originalValue == null) { return null; } String templateId = (String) context.getAttributes().get(SERVER_TEMPLATE_ID); return fromDocument(originalValue, templateId); } @Inject  DocumentFieldValueMarshaller(UploadedDocumentStorage documentStorage); @Override Class<DocumentFieldDefinition> getSupportedField(); @Override Supplier<FieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition>> newInstanceSupplier(); @Override DocumentData toFlatValue(); @Override Document toRawValue(DocumentData documentData); static final String SERVER_TEMPLATE_ID; }