@Test public void testRunBackupWithDir() throws Exception { final Collection<Throwable> problems = new ArrayList<>(); when(mockService.restoreRepository(any(Session.class), any(File.class))).thenReturn(problems); final String tmpDir = System.getProperty("java.io.tmpdir"); final InputStream inputStream = new ByteArrayInputStream(tmpDir.getBytes()); final Response response = repoRestore.runRestore(inputStream); assertNotNull(response); assertEquals(204, response.getStatus()); }
@Test public void testRunBackup() throws Exception { final Collection<Throwable> problems = new ArrayList<>(); when(mockService.backupRepository(any(Session.class), any(File.class))).thenReturn(problems); boolean thrown = false; try { repoRestore.runRestore(null); fail("Exception expected"); } catch (final WebApplicationException e) { thrown = true; } assertTrue(thrown); }