Search in sources :

Example 31 with Timestamp

use of java.sql.Timestamp in project head by mifos.

the class SavingsAdjustmentAccountingEntryTest method setUpOneVoluntarySavingsTest.

private void setUpOneVoluntarySavingsTest(SavingsType savingsType, AccountActionTypes accountActionType, GLCategoryType bankCategoryType, GLCategoryType savingsCategoryType, FinancialConstants debitOrCreditToBankGLAccount, FinancialActionConstants financialAction) throws FinancialException {
    when(mockedFinancialActivity.getAccountTrxn()).thenReturn(mockedIncomingTransaction);
    when(mockedIncomingTransaction.getAccount()).thenReturn(mockedSavingsBO);
    when(mockedIncomingTransaction.getWithdrawlAmount()).thenReturn(withdrawalAmount);
    when(mockedIncomingTransaction.getDepositAmount()).thenReturn(depositAmount);
    when(mockedIncomingTransaction.getActionDate()).thenReturn(transactionActionDate.toDate());
    when(mockedIncomingTransaction.getTrxnCreatedDate()).thenReturn(new Timestamp(transactionPostedDate.getMillis()));
    when(mockedIncomingTransaction.getPersonnel()).thenReturn(mockedTransactionCreator);
    when(mockedIncomingTransaction.getComments()).thenReturn(commentString);
    when(mockedSavingsBO.getSavingsOffering()).thenReturn(mockedSavingsOffering);
    when(mockedSavingsBO.isMandatory()).thenReturn(false);
    when(mockedSavingsBO.isVoluntary()).thenReturn(true);
    when(mockedSavingsOffering.getDepositGLCode()).thenReturn(mockedSavingsDepositGLCode);
    when(mockedSavingsDepositGLCode.getGlcode()).thenReturn(savingsDepositGLCodeString);
    when(mockedSavingsGLAccount.getGlCode()).thenReturn(savingsDepositGLCodeString);
    when(mockedSavingsGLAccount.getAccountName()).thenReturn("Clients Accounts");
    when(mockedSavingsGLAccount.getTopLevelCategoryType()).thenReturn(savingsCategoryType);
    when(mockedBankGLAccount.getAssociatedGlcode()).thenReturn(mockedBankGLCode);
    when(mockedBankGLAccount.getGlCode()).thenReturn(bankGLCodeString);
    when(mockedBankGLAccount.getTopLevelCategoryType()).thenReturn(bankCategoryType);
    when(mockedBankGLCode.getGlcode()).thenReturn(bankGLCodeString);
    when(mockedFinancialBusinessService.getGlAccount(savingsDepositGLCodeString)).thenReturn(mockedSavingsGLAccount);
    when(mockedFinancialBusinessService.getGlAccount(bankGLCodeString)).thenReturn(mockedBankGLAccount);
    when(mockedFinancialBusinessService.getFinancialAction(financialAction)).thenReturn(mockedFinancialAction);
    if (debitOrCreditToBankGLAccount.equals(FinancialConstants.DEBIT)) {
        when(mockedFinancialAction.getApplicableDebitCharts()).thenReturn(setWith(mockedBankGLAccount));
    } else {
        when(mockedFinancialAction.getApplicableCreditCharts()).thenReturn(setWith(mockedBankGLAccount));
    }
    when(mockedSavingsType.getId()).thenReturn(savingsType.getValue());
    when(mockedSavingsHelper.getPaymentActionType((AccountPaymentEntity) any())).thenReturn(accountActionType.getValue());
}
Also used : Timestamp(java.sql.Timestamp)

Example 32 with Timestamp

use of java.sql.Timestamp in project head by mifos.

the class SavingsAdjustmentAccountingEntryTest method setUpOneMandatorySavingsTest.

private void setUpOneMandatorySavingsTest(SavingsType savingsType, AccountActionTypes accountActionType, GLCategoryType bankCategoryType, GLCategoryType savingsCategoryType, FinancialConstants debitOrCreditToBankGLAccount, FinancialActionConstants financialAction) throws FinancialException {
    when(mockedFinancialActivity.getAccountTrxn()).thenReturn(mockedIncomingTransaction);
    when(mockedIncomingTransaction.getAccount()).thenReturn(mockedSavingsBO);
    when(mockedIncomingTransaction.getWithdrawlAmount()).thenReturn(withdrawalAmount);
    when(mockedIncomingTransaction.getDepositAmount()).thenReturn(depositAmount);
    when(mockedIncomingTransaction.getActionDate()).thenReturn(transactionActionDate.toDate());
    when(mockedIncomingTransaction.getTrxnCreatedDate()).thenReturn(new Timestamp(transactionPostedDate.getMillis()));
    when(mockedIncomingTransaction.getPersonnel()).thenReturn(mockedTransactionCreator);
    when(mockedIncomingTransaction.getComments()).thenReturn(commentString);
    when(mockedSavingsBO.getSavingsOffering()).thenReturn(mockedSavingsOffering);
    when(mockedSavingsBO.isMandatory()).thenReturn(true);
    when(mockedSavingsOffering.getDepositGLCode()).thenReturn(mockedSavingsDepositGLCode);
    when(mockedSavingsDepositGLCode.getGlcode()).thenReturn(savingsDepositGLCodeString);
    when(mockedSavingsGLAccount.getGlCode()).thenReturn(savingsDepositGLCodeString);
    when(mockedSavingsGLAccount.getAccountName()).thenReturn("Clients Accounts");
    when(mockedSavingsGLAccount.getTopLevelCategoryType()).thenReturn(savingsCategoryType);
    when(mockedBankGLAccount.getAssociatedGlcode()).thenReturn(mockedBankGLCode);
    when(mockedBankGLAccount.getGlCode()).thenReturn(bankGLCodeString);
    when(mockedBankGLAccount.getTopLevelCategoryType()).thenReturn(bankCategoryType);
    when(mockedBankGLCode.getGlcode()).thenReturn(bankGLCodeString);
    when(mockedFinancialBusinessService.getGlAccount(savingsDepositGLCodeString)).thenReturn(mockedSavingsGLAccount);
    when(mockedFinancialBusinessService.getGlAccount(bankGLCodeString)).thenReturn(mockedBankGLAccount);
    when(mockedFinancialBusinessService.getFinancialAction(financialAction)).thenReturn(mockedFinancialAction);
    if (debitOrCreditToBankGLAccount.equals(FinancialConstants.DEBIT)) {
        when(mockedFinancialAction.getApplicableDebitCharts()).thenReturn(setWith(mockedBankGLAccount));
    } else {
        when(mockedFinancialAction.getApplicableCreditCharts()).thenReturn(setWith(mockedBankGLAccount));
    }
    when(mockedSavingsType.getId()).thenReturn(savingsType.getValue());
    when(mockedSavingsHelper.getPaymentActionType((AccountPaymentEntity) any())).thenReturn(accountActionType.getValue());
}
Also used : Timestamp(java.sql.Timestamp)

Example 33 with Timestamp

use of java.sql.Timestamp in project pinot by linkedin.

the class StarTreeClusterIntegrationTest method waitForExternalViewUpdate.

/**
   * Wait for External View to be in sync with Ideal State.
   * @return
   */
private boolean waitForExternalViewUpdate() {
    final ZKHelixAdmin helixAdmin = new ZKHelixAdmin(ZkStarter.DEFAULT_ZK_STR);
    ClusterStateVerifier.Verifier customVerifier = new ClusterStateVerifier.Verifier() {

        @Override
        public boolean verify() {
            String clusterName = getHelixClusterName();
            List<String> resourcesInCluster = helixAdmin.getResourcesInCluster(clusterName);
            LOGGER.info("Waiting for external view to update for resources: {} startTime: {}", resourcesInCluster, new Timestamp(System.currentTimeMillis()));
            for (String resourceName : resourcesInCluster) {
                IdealState idealState = helixAdmin.getResourceIdealState(clusterName, resourceName);
                ExternalView externalView = helixAdmin.getResourceExternalView(clusterName, resourceName);
                LOGGER.info("HERE for {},\n IS:{} \n EV:{}", resourceName, idealState, externalView);
                if (idealState == null || externalView == null) {
                    return false;
                }
                Set<String> partitionSet = idealState.getPartitionSet();
                for (String partition : partitionSet) {
                    Map<String, String> instanceStateMapIS = idealState.getInstanceStateMap(partition);
                    Map<String, String> instanceStateMapEV = externalView.getStateMap(partition);
                    if (instanceStateMapIS == null || instanceStateMapEV == null) {
                        return false;
                    }
                    if (!instanceStateMapIS.equals(instanceStateMapEV)) {
                        return false;
                    }
                }
                LOGGER.info("External View updated successfully for {},\n IS:{} \n EV:{}", resourceName, idealState, externalView);
            }
            LOGGER.info("External View updated successfully for {}", resourcesInCluster);
            return true;
        }
    };
    return ClusterStateVerifier.verifyByPolling(customVerifier, TIMEOUT_IN_MILLISECONDS);
}
Also used : ExternalView(org.apache.helix.model.ExternalView) ZKHelixAdmin(org.apache.helix.manager.zk.ZKHelixAdmin) ClusterStateVerifier(org.apache.helix.tools.ClusterStateVerifier) ClusterStateVerifier(org.apache.helix.tools.ClusterStateVerifier) Timestamp(java.sql.Timestamp) IdealState(org.apache.helix.model.IdealState)

Example 34 with Timestamp

use of java.sql.Timestamp in project head by mifos.

the class ImportedFilesDaoHibernateIntegrationTest method testSaveConstraintVoilation.

/**
     * ignoring as can't get first
     */
@Test(expected = MifosRuntimeException.class)
public void testSaveConstraintVoilation() throws Exception {
    Short personnelId = new Short("1");
    PersonnelBO personnelBO = TestObjectFactory.getPersonnel(personnelId);
    Timestamp timeStamp = new Timestamp(123134554L);
    String fileName = "testFile.xls";
    ImportedFilesEntity expected = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
    StaticHibernateUtil.startTransaction();
    importedFilesDao.saveImportedFile(expected);
    StaticHibernateUtil.flushSession();
    ImportedFilesEntity shouldViolateConstraint = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
    importedFilesDao.saveImportedFile(shouldViolateConstraint);
    StaticHibernateUtil.flushSession();
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Timestamp(java.sql.Timestamp) ImportedFilesEntity(org.mifos.application.importexport.business.ImportedFilesEntity) Test(org.junit.Test)

Example 35 with Timestamp

use of java.sql.Timestamp in project head by mifos.

the class ImportedFilesDaoHibernateIntegrationTest method testSaveAndFind.

@Test
public void testSaveAndFind() throws Exception {
    Short personnelId = new Short("1");
    PersonnelBO personnelBO = TestObjectFactory.getPersonnel(personnelId);
    Timestamp timeStamp = new Timestamp(123134554L);
    String fileName = "testFile.xls";
    ImportedFilesEntity expected = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
    StaticHibernateUtil.startTransaction();
    importedFilesDao.saveImportedFile(expected);
    StaticHibernateUtil.flushSession();
    ImportedFilesEntity actual = importedFilesDao.findImportedFileByName(fileName);
    Assert.assertEquals(fileName, actual.getFileName());
    Assert.assertEquals(personnelId, actual.getSubmittedBy().getPersonnelId());
    Assert.assertEquals(timeStamp, actual.getSubmittedOn());
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Timestamp(java.sql.Timestamp) ImportedFilesEntity(org.mifos.application.importexport.business.ImportedFilesEntity) Test(org.junit.Test)

Aggregations

Timestamp (java.sql.Timestamp)3153 Test (org.junit.Test)526 Date (java.util.Date)458 PreparedStatement (java.sql.PreparedStatement)450 SQLException (java.sql.SQLException)367 ResultSet (java.sql.ResultSet)353 BigDecimal (java.math.BigDecimal)351 ArrayList (java.util.ArrayList)236 Date (java.sql.Date)218 Connection (java.sql.Connection)216 HashMap (java.util.HashMap)201 GenericValue (org.apache.ofbiz.entity.GenericValue)194 Calendar (java.util.Calendar)184 Time (java.sql.Time)173 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)167 Delegator (org.apache.ofbiz.entity.Delegator)157 SimpleDateFormat (java.text.SimpleDateFormat)150 IOException (java.io.IOException)129 Locale (java.util.Locale)129 Map (java.util.Map)111