@Test public void testExistingFlatValue2Document() { Document doc = new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date(), "aLink"); marshaller.init(doc, field, form, context); DocumentData data = new DocumentData(doc.getName(), doc.getSize(), doc.getLink()); data.setStatus(DocumentStatus.STORED); Document rawDoc = marshaller.toRawValue(data); assertEquals("Documents must be equal!", doc, rawDoc); verify(documentStorage, never()).getContent(anyString()); verify(documentStorage, never()).removeContent(anyString()); }
@Override public Document toRawValue(DocumentData documentData) { if (documentData == null) { return null; } if (documentData.getStatus().equals(DocumentStatus.STORED)) { return originalValue; } return toDocument(documentData, documentStorage); }
DocumentFieldValueMarshaller extends AbstractFieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition> { @Override public Document toRawValue(DocumentData documentData) { if (documentData == null) { return null; } if (documentData.getStatus().equals(DocumentStatus.STORED)) { return originalValue; } return toDocument(documentData, documentStorage); } }
DocumentFieldValueMarshaller extends AbstractFieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition> { @Override public Document toRawValue(DocumentData documentData) { if (documentData == null) { return null; } if (documentData.getStatus().equals(DocumentStatus.STORED)) { return originalValue; } return toDocument(documentData, documentStorage); } @Inject  DocumentFieldValueMarshaller(UploadedDocumentStorage documentStorage); }
DocumentFieldValueMarshaller extends AbstractFieldValueMarshaller<Document, DocumentData, DocumentFieldDefinition> { @Override public Document toRawValue(DocumentData documentData) { if (documentData == null) { return null; } if (documentData.getStatus().equals(DocumentStatus.STORED)) { return originalValue; } return toDocument(documentData, documentStorage); } @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 Document toRawValue(DocumentData documentData) { if (documentData == null) { return null; } if (documentData.getStatus().equals(DocumentStatus.STORED)) { return originalValue; } return toDocument(documentData, documentStorage); } @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; }