Job { @Api(2.0) @NonNull public JobInfo info() { return mBuilder.mJobInfo; } private  Job(@NonNull Builder builder); private  Job(); @Override boolean equals(Object o); @Api(2.0) @NonNull JobInfo info(); @Api(2.0) @NonNull Act action(); @Api(2.0) @NonNull Map<String, Boolean> conditionsOk(); @Api(2.0) boolean canBePersisted(); @NonNull @Api(2.0) List<Trigger> triggers(); static Job.Builder builder(@NonNull Act action); static final int NETWORK_TYPE_NONE; static final int NETWORK_TYPE_ANY; static final int NETWORK_TYPE_UNMETERED; }
@Test public void thatCanPersistJobInfoToFileAndDelete() throws IOException { Job job = givenAJob(mCallbackFlag,"job"); String pathFile = getPathToFileResource(); File fileJobInfo = new File(pathFile); File fileToVerify = new File(pathFile, job.info().mIdentity + ".job"); job.info().writeToFile(fileJobInfo); job.info().tryDelete(fileJobInfo); assertThat(fileJobInfo.isDirectory()).isTrue(); assertThat(fileToVerify.exists()).isFalse(); }
@Test public void thatCanPersistJobInfoWithTriggerToFileAndDelete() throws IOException { Job job = givenAJobWithTrigger(mCallbackFlag); String pathFile = getPathToFileResource(); File fileJobInfo = new File(pathFile); File fileToVerify = new File(pathFile, job.info().mIdentity + ".job"); job.info().writeToFile(fileJobInfo); job.info().tryDelete(fileJobInfo); assertThat(fileJobInfo.isDirectory()).isTrue(); assertThat(fileToVerify.exists()).isFalse(); }