Search in sources :

Example 6 with PersistableBusinessObject

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());
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Attachment(org.kuali.kfs.krad.bo.Attachment) DummyAntiVirusServiceImpl(edu.cornell.cynergy.antivirus.service.DummyAntiVirusServiceImpl) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 7 with PersistableBusinessObject

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");
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 8 with PersistableBusinessObject

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");
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) Test(org.junit.Test)

Example 9 with PersistableBusinessObject

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");
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 10 with PersistableBusinessObject

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);
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) FinancialSystemMaintenanceDocument(org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader) Maintainable(org.kuali.kfs.kns.maintenance.Maintainable) FinancialSystemMaintainable(org.kuali.kfs.sys.document.FinancialSystemMaintainable)

Aggregations

PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)21 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 BufferedInputStream (java.io.BufferedInputStream)5 FileInputStream (java.io.FileInputStream)5 InputStream (java.io.InputStream)5 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)4 FavoriteAccount (edu.cornell.kfs.sys.businessobject.FavoriteAccount)2 Maintainable (org.kuali.kfs.kns.maintenance.Maintainable)2 Note (org.kuali.kfs.krad.bo.Note)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 DummyAntiVirusServiceImpl (edu.cornell.cynergy.antivirus.service.DummyAntiVirusServiceImpl)1 AccountReversionService (edu.cornell.kfs.coa.service.AccountReversionService)1 UserProcurementProfile (edu.cornell.kfs.sys.businessobject.UserProcurementProfile)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1