Exemplo n.º 1
0
  @Before
  public void setUp() {

    dateStart.setTime(DateUtil.parseDateTime("20140101").toDate());
    dateStart.set(Calendar.HOUR_OF_DAY, 0);
    dateStart.set(Calendar.MINUTE, 0);
    dateStart.set(Calendar.SECOND, 0);
    dateStart.add(Calendar.HOUR, 12);

    dateStartLastMinute.setTime(DateUtil.parseDateTime("20140101").toDate());
    dateStartLastMinute.set(Calendar.HOUR_OF_DAY, 23);
    dateStartLastMinute.set(Calendar.MINUTE, 59);
    dateStartLastMinute.set(Calendar.SECOND, 59);
    dateStartLastMinute.add(Calendar.HOUR, 12);

    // creating one list wuth 3 nonMCC accounts
    Account account1 = new Account();
    account1.setId("123");
    account1.setTopAccountId(456L);
    account1.setCanManageClients(false);
    accountList = ImmutableList.of(account1, account1, account1);

    storageHelper = new StorageHelper();

    mockedRunnableKratu =
        new RunnableKratu(456L, accountList, storageHelper, dateStart.getTime(), dateEnd);

    MockitoAnnotations.initMocks(this);

    when(mockedEntitiesPersister.get(Account.class, "topAccountId", 456L)).thenReturn(accountList);
    storageHelper.setPersister(mockedEntitiesPersister);
  }
  public void run() {
    try {

      LOGGER.debug("Creating ReportProcessor bean...");

      processor.generateReportsForMCC(
          String.valueOf(topAccountId),
          ReportDefinitionDateRangeType.CUSTOM_DATE,
          DateUtil.formatYearMonthDayNoDash(dateStart),
          DateUtil.formatYearMonthDayNoDash(dateEnd),
          null,
          properties,
          null,
          null);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 3
0
/**
 * Test case for the {@code RunnableKratu} class.
 *
 * @author [email protected] (Julian Toledo)
 */
public class RunnableKratuTest {

  @Spy private RunnableKratu mockedRunnableKratu;

  @Mock private EntityPersister mockedEntitiesPersister;

  private StorageHelper storageHelper;

  private ImmutableList<Account> accountList;

  private final Calendar dateStart = Calendar.getInstance();
  private final Calendar dateStartLastMinute = Calendar.getInstance();

  private final Date dateEnd = DateUtil.parseDateTime("20140131").toDate();

  @Before
  public void setUp() {

    dateStart.setTime(DateUtil.parseDateTime("20140101").toDate());
    dateStart.set(Calendar.HOUR_OF_DAY, 0);
    dateStart.set(Calendar.MINUTE, 0);
    dateStart.set(Calendar.SECOND, 0);
    dateStart.add(Calendar.HOUR, 12);

    dateStartLastMinute.setTime(DateUtil.parseDateTime("20140101").toDate());
    dateStartLastMinute.set(Calendar.HOUR_OF_DAY, 23);
    dateStartLastMinute.set(Calendar.MINUTE, 59);
    dateStartLastMinute.set(Calendar.SECOND, 59);
    dateStartLastMinute.add(Calendar.HOUR, 12);

    // creating one list wuth 3 nonMCC accounts
    Account account1 = new Account();
    account1.setId("123");
    account1.setTopAccountId(456L);
    account1.setCanManageClients(false);
    accountList = ImmutableList.of(account1, account1, account1);

    storageHelper = new StorageHelper();

    mockedRunnableKratu =
        new RunnableKratu(456L, accountList, storageHelper, dateStart.getTime(), dateEnd);

    MockitoAnnotations.initMocks(this);

    when(mockedEntitiesPersister.get(Account.class, "topAccountId", 456L)).thenReturn(accountList);
    storageHelper.setPersister(mockedEntitiesPersister);
  }

  @Test
  public void testRun()
      throws FileNotFoundException, ValidationException, ReportException,
          ReportDownloadResponseException, IOException {

    mockedRunnableKratu.run();
    verify(mockedRunnableKratu, times(1)).run();

    verify(mockedEntitiesPersister, times(3))
        .get(
            ReportAccount.class,
            Report.ACCOUNT_ID,
            123L,
            Report.DAY,
            dateStart.getTime(),
            dateStartLastMinute.getTime());
  }
}