Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rivaldi8 committed Apr 27, 2017
1 parent a74311a commit 0a5af15
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.gnucash.android.util.BookUtils;
import org.gnucash.android.util.TimestampHelper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.LocalDateTime;
import org.joda.time.Weeks;
import org.junit.After;
Expand All @@ -63,6 +64,8 @@
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;

import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -199,8 +202,10 @@ public void missedScheduledTransactions_shouldBeGenerated(){

scheduledAction.setActionUID(mActionUID);

int multiplier = 2;
scheduledAction.setRecurrence(PeriodType.WEEK, multiplier);
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
recurrence.setMultiplier(2);
recurrence.setByDays(Collections.singletonList(Calendar.MONDAY));
scheduledAction.setRecurrence(recurrence);
ScheduledActionDbAdapter.getInstance().addRecord(scheduledAction, DatabaseAdapter.UpdateMethod.insert);

TransactionsDbAdapter transactionsDbAdapter = TransactionsDbAdapter.getInstance();
Expand Down Expand Up @@ -249,7 +254,10 @@ public void scheduledTransactionsWithEndTimeInPast_shouldBeExecuted(){
scheduledAction.setStartTime(startTime.getMillis());
scheduledAction.setActionUID(mActionUID);

scheduledAction.setRecurrence(PeriodType.WEEK, 2);
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
recurrence.setMultiplier(2);
recurrence.setByDays(Collections.singletonList(Calendar.MONDAY));
scheduledAction.setRecurrence(recurrence);
scheduledAction.setEndTime(new DateTime(2016, 8, 8, 9, 0).getMillis());
ScheduledActionDbAdapter.getInstance().addRecord(scheduledAction, DatabaseAdapter.UpdateMethod.insert);

Expand Down Expand Up @@ -345,11 +353,15 @@ public void scheduledBackups_shouldRunOnlyOnce(){
@Test
public void scheduledBackups_shouldNotRunBeforeNextScheduledExecution(){
ScheduledAction scheduledBackup = new ScheduledAction(ScheduledAction.ActionType.BACKUP);
scheduledBackup.setStartTime(LocalDateTime.now().minusDays(2).toDate().getTime());
scheduledBackup.setStartTime(
LocalDateTime.now().withDayOfWeek(DateTimeConstants.WEDNESDAY).toDate().getTime());
scheduledBackup.setLastRun(scheduledBackup.getStartTime());
long previousLastRun = scheduledBackup.getLastRunTime();
scheduledBackup.setExecutionCount(1);
scheduledBackup.setRecurrence(PeriodType.WEEK, 1);
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
recurrence.setMultiplier(1);
recurrence.setByDays(Collections.singletonList(Calendar.MONDAY));
scheduledBackup.setRecurrence(recurrence);

ExportParams backupParams = new ExportParams(ExportFormat.XML);
backupParams.setExportTarget(ExportParams.ExportTarget.SD_CARD);
Expand Down Expand Up @@ -380,7 +392,10 @@ public void scheduledBackups_shouldNotIncludeTransactionsPreviousToTheLastRun()
scheduledBackup.setLastRun(LocalDateTime.now().minusDays(8).toDate().getTime());
long previousLastRun = scheduledBackup.getLastRunTime();
scheduledBackup.setExecutionCount(1);
scheduledBackup.setRecurrence(PeriodType.WEEK, 1);
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
recurrence.setMultiplier(1);
recurrence.setByDays(Collections.singletonList(Calendar.WEDNESDAY));
scheduledBackup.setRecurrence(recurrence);
ExportParams backupParams = new ExportParams(ExportFormat.QIF);
backupParams.setExportTarget(ExportParams.ExportTarget.SD_CARD);
backupParams.setExportStartTime(new Timestamp(scheduledBackup.getStartTime()));
Expand Down Expand Up @@ -438,7 +453,10 @@ public void scheduledBackups_shouldIncludeTransactionsAfterTheLastRun() {
scheduledBackup.setLastRun(LocalDateTime.now().minusDays(8).toDate().getTime());
long previousLastRun = scheduledBackup.getLastRunTime();
scheduledBackup.setExecutionCount(1);
scheduledBackup.setRecurrence(PeriodType.WEEK, 1);
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
recurrence.setMultiplier(1);
recurrence.setByDays(Collections.singletonList(Calendar.FRIDAY));
scheduledBackup.setRecurrence(recurrence);
ExportParams backupParams = new ExportParams(ExportFormat.QIF);
backupParams.setExportTarget(ExportParams.ExportTarget.SD_CARD);
backupParams.setExportStartTime(new Timestamp(scheduledBackup.getStartTime()));
Expand Down

0 comments on commit 0a5af15

Please sign in to comment.