use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.
the class CuAttachmentServiceImplTest method createAttachment.
@Test
public void createAttachment() throws Exception {
attachmentService.setAntiVirusService(new DummyAntiVirusServiceImpl());
PersistableBusinessObject pbo = setupPersistableBusinessObject();
InputStream inputStream = setupInputStream(ATTACHMENT_TEST_FILE_PATH + File.separator + GOOD_FILE_NAME);
Attachment createdAttachment = attachmentService.createAttachment(pbo, GOOD_FILE_NAME, "txt", 10, inputStream, "txt");
InputStream createdInputStream = new BufferedInputStream(new FileInputStream(buildDocumentDirectory(pbo.getObjectId()) + File.separator + createdAttachment.getAttachmentIdentifier()));
String fileContents = IOUtils.toString(createdInputStream, "UTF-8");
Assert.assertEquals(GOOD_FILE_CONTENTS, fileContents);
Assert.assertEquals(GOOD_FILE_NAME, createdAttachment.getAttachmentFileName());
Assert.assertEquals(10L, createdAttachment.getAttachmentFileSize().longValue());
Assert.assertEquals("txt", createdAttachment.getAttachmentMimeTypeCode());
Assert.assertEquals("txt", createdAttachment.getAttachmentTypeCode());
}
use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.
the class CuAttachmentServiceImplTest method createAttachmentWithVirusInvalidMimeType.
@Test
public void createAttachmentWithVirusInvalidMimeType() throws Exception {
PersistableBusinessObject pbo = setupPersistableBusinessObject();
InputStream inputStream = setupInputStream(ATTACHMENT_TEST_FILE_PATH + File.separator + GOOD_FILE_NAME);
setupExpectedException("invalid (blank) mimeType");
attachmentService.createAttachment(pbo, GOOD_FILE_NAME, "", 50, inputStream, "txt");
}
use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.
the class CuAttachmentServiceImplTest method createAttachmentWithVirusInvalidInputStream.
@Test
public void createAttachmentWithVirusInvalidInputStream() throws Exception {
PersistableBusinessObject pbo = setupPersistableBusinessObject();
setupExpectedException("invalid (null) inputStream");
attachmentService.createAttachment(pbo, GOOD_FILE_NAME, "txt", 50, null, "txt");
}
use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.
the class CuAttachmentServiceImplTest method createAttachmentWithVirusInvalidFileName.
@Test
public void createAttachmentWithVirusInvalidFileName() throws Exception {
PersistableBusinessObject pbo = setupPersistableBusinessObject();
InputStream inputStream = setupInputStream(ATTACHMENT_TEST_FILE_PATH + File.separator + GOOD_FILE_NAME);
setupExpectedException("invalid (blank) fileName");
attachmentService.createAttachment(pbo, "", "txt", 50, inputStream, "txt");
}
use of org.kuali.kfs.krad.bo.PersistableBusinessObject in project cu-kfs by CU-CommunityApps.
the class CuFinancialMaintenanceDocumentActionTest method setupMockMaintenanceDocument.
protected void setupMockMaintenanceDocument(Class<? extends PersistableBusinessObject> dataObjectClass, DocumentStatus documentStatus, String objectId) {
Maintainable mockMaintainable = createMockMaintainable(dataObjectClass, objectId);
PersistableBusinessObject mockDataObject = (PersistableBusinessObject) mockMaintainable.getDataObject();
DocumentHeader mockDocumentHeader = createMockDocumentHeader(documentStatus);
testDocument = mock(FinancialSystemMaintenanceDocument.class);
when(((FinancialSystemMaintenanceDocument) testDocument).getNewMaintainableObject()).thenReturn(mockMaintainable);
when(testDocument.getNoteTarget()).thenReturn(mockDataObject);
when(testDocument.getDocumentHeader()).thenReturn(mockDocumentHeader);
}
Aggregations