@Test public void testExecute_missingDataStoreName() throws Exception { H2BackupTask task = createTask(null, "/foo/bar.zip"); thrown.expect(NullPointerException.class); thrown.expectMessage("DataStore name not configured"); task.execute(); }
@Override protected Object execute() throws Exception { String dataStoreName = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.DATASTORE), "DataStore name not configured"); String location = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.LOCATION), "Backup location not configured"); Optional<DataStore<?>> dataStore = dataStoreManager.get(dataStoreName); if (!dataStore.isPresent()) { throw new RuntimeException("Unable to locate datastore with name " + dataStoreName); } location = handleRelative(location); location = interpolate(location); log.info("Starting backup of {} to {}", dataStoreName, location); long start = System.currentTimeMillis(); dataStore.get().backup(location); log.info("Completed backup of {} in {} ms", dataStoreName, System.currentTimeMillis() - start); return null; }
H2BackupTask extends TaskSupport { @Override protected Object execute() throws Exception { String dataStoreName = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.DATASTORE), "DataStore name not configured"); String location = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.LOCATION), "Backup location not configured"); Optional<DataStore<?>> dataStore = dataStoreManager.get(dataStoreName); if (!dataStore.isPresent()) { throw new RuntimeException("Unable to locate datastore with name " + dataStoreName); } location = handleRelative(location); location = interpolate(location); log.info("Starting backup of {} to {}", dataStoreName, location); long start = System.currentTimeMillis(); dataStore.get().backup(location); log.info("Completed backup of {} in {} ms", dataStoreName, System.currentTimeMillis() - start); return null; } }
H2BackupTask extends TaskSupport { @Override protected Object execute() throws Exception { String dataStoreName = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.DATASTORE), "DataStore name not configured"); String location = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.LOCATION), "Backup location not configured"); Optional<DataStore<?>> dataStore = dataStoreManager.get(dataStoreName); if (!dataStore.isPresent()) { throw new RuntimeException("Unable to locate datastore with name " + dataStoreName); } location = handleRelative(location); location = interpolate(location); log.info("Starting backup of {} to {}", dataStoreName, location); long start = System.currentTimeMillis(); dataStore.get().backup(location); log.info("Completed backup of {} in {} ms", dataStoreName, System.currentTimeMillis() - start); return null; } @Inject  H2BackupTask(final DataStoreManager dataStoreManager, final ApplicationDirectories applicationDirectories); }
H2BackupTask extends TaskSupport { @Override protected Object execute() throws Exception { String dataStoreName = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.DATASTORE), "DataStore name not configured"); String location = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.LOCATION), "Backup location not configured"); Optional<DataStore<?>> dataStore = dataStoreManager.get(dataStoreName); if (!dataStore.isPresent()) { throw new RuntimeException("Unable to locate datastore with name " + dataStoreName); } location = handleRelative(location); location = interpolate(location); log.info("Starting backup of {} to {}", dataStoreName, location); long start = System.currentTimeMillis(); dataStore.get().backup(location); log.info("Completed backup of {} in {} ms", dataStoreName, System.currentTimeMillis() - start); return null; } @Inject  H2BackupTask(final DataStoreManager dataStoreManager, final ApplicationDirectories applicationDirectories); @Override String getMessage(); }
H2BackupTask extends TaskSupport { @Override protected Object execute() throws Exception { String dataStoreName = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.DATASTORE), "DataStore name not configured"); String location = checkNotNull(getConfiguration().getString(H2BackupTaskDescriptor.LOCATION), "Backup location not configured"); Optional<DataStore<?>> dataStore = dataStoreManager.get(dataStoreName); if (!dataStore.isPresent()) { throw new RuntimeException("Unable to locate datastore with name " + dataStoreName); } location = handleRelative(location); location = interpolate(location); log.info("Starting backup of {} to {}", dataStoreName, location); long start = System.currentTimeMillis(); dataStore.get().backup(location); log.info("Completed backup of {} in {} ms", dataStoreName, System.currentTimeMillis() - start); return null; } @Inject  H2BackupTask(final DataStoreManager dataStoreManager, final ApplicationDirectories applicationDirectories); @Override String getMessage();  }