@Test(expected = NullPointerException.class) public void saveDocumentoTemporalFailsIfNotTipo() throws Exception { Documento documento = stubDocumento(); documento.tipo = null; InputStream is = new ByteArrayInputStream("".getBytes()); gestorDocumentalService.saveDocumentoTemporal(documento, is, TEST_FILENAME); }
@Test(expected = GestorDocumentalServiceException.class) public void saveDocumentoTemporalFailsIfUri() throws Exception { Documento documento = stubDocumento(); documento.uri = "uri ya seteada"; InputStream is = new ByteArrayInputStream("contenido".getBytes()); gestorDocumentalService.saveDocumentoTemporal(documento, is, TEST_FILENAME); }
@Test public void saveDocumentoTemporalByFile() throws Exception { Documento documento = stubDocumento(); File f = Play.getVirtualFile("/test/services/aedTest.txt").getRealFile(); String uri = gestorDocumentalService.saveDocumentoTemporal(documento, f); assertSubidaDocumentoCorrecta(documento, uri); }
@Test(expected = IllegalArgumentException.class) public void saveDocumentoTemporalFailsIfOtrosAndEmptyDescripcion() throws Exception { Documento documento = new Documento(); documento.tipo = getTipoDocumentoValido(); documento.descripcion = ""; InputStream is = new ByteArrayInputStream("".getBytes()); gestorDocumentalService.saveDocumentoTemporal(documento, is, TEST_FILENAME); }
@Test public void saveDocumentoTemporal() throws Exception { InputStream is = new ByteArrayInputStream(TEST_FILE_CONTENT.getBytes()); Documento documento = stubDocumento(); String uri = gestorDocumentalService.saveDocumentoTemporal(documento, is, TEST_FILENAME); assertSubidaDocumentoCorrecta(documento, uri); }
private Documento saveTmpDocumento(String fileContent, String filename) throws Exception { InputStream is = new ByteArrayInputStream(fileContent.getBytes()); Documento documento = stubDocumento(); gestorDocumentalService.saveDocumentoTemporal(documento, is, filename); return documento; }
@Test(expected = NullPointerException.class) public void saveDocumentoTemporalFailsIfNullStream() throws Exception { Documento documento = stubDocumento(); gestorDocumentalService.saveDocumentoTemporal(documento, null, TEST_FILENAME); }
@Test(expected = GestorDocumentalServiceException.class) public void saveDocumentoTemporalFailsIfEmptyStream() throws Exception { Documento documento = stubDocumento(); InputStream is = new ByteArrayInputStream("".getBytes()); gestorDocumentalService.saveDocumentoTemporal(documento, is, TEST_FILENAME); }