MIFOSX-1216 and loan integration tests with accounting

This commit is contained in:
Madhukar
2014-06-03 10:36:12 +05:30
parent a3a414ff0a
commit d80e574b3b
9 changed files with 1858 additions and 41 deletions
@@ -22,7 +22,6 @@ import org.mifosplatform.infrastructure.security.service.SpringSecurityPlatformS
import org.mifosplatform.useradministration.data.RoleData;
import org.mifosplatform.useradministration.domain.AppUser;
import org.mifosplatform.useradministration.domain.Role;
import org.mifosplatform.useradministration.exception.UserNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
@@ -59,10 +58,6 @@ public class AuthenticationApiResource {
final Authentication authentication = new UsernamePasswordAuthenticationToken(username, password);
final Authentication authenticationCheck = this.customAuthenticationProvider.authenticate(authentication);
final AppUser principal = (AppUser) authenticationCheck.getPrincipal();
if (principal.isDeleted() || principal.isNotEnabled() ) {
throw new UserNotFoundException(principal.getId());
}
final Collection<String> permissions = new ArrayList<String>();
AuthenticatedUserData authenticatedUserData = new AuthenticatedUserData(username, permissions);
@@ -75,6 +70,7 @@ public class AuthenticationApiResource {
final byte[] base64EncodedAuthenticationKey = Base64.encode(username + ":" + password);
final AppUser principal = (AppUser) authenticationCheck.getPrincipal();
final Collection<RoleData> roles = new ArrayList<RoleData>();
final Set<Role> userRoles = principal.getRoles();
for (final Role role : userRoles) {
@@ -7,6 +7,6 @@ package org.mifosplatform.infrastructure.security.domain;
public interface PlatformUserRepository {
PlatformUser findByUsername(String username);
PlatformUser findByUsernameAndDeletedAndEnabled(String username, boolean deleted, boolean enabled);
}
@@ -29,7 +29,11 @@ public class TenantAwareJpaPlatformUserDetailsService implements PlatformUserDet
@Cacheable(value = "usersByUsername", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#username+'ubu')")
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException, DataAccessException {
final PlatformUser appUser = this.platformUserRepository.findByUsername(username);
// Retrieve active users only
final boolean deleted = false;
final boolean enabled = true;
final PlatformUser appUser = this.platformUserRepository.findByUsernameAndDeletedAndEnabled(username, deleted, enabled);
if (appUser == null) { throw new UsernameNotFoundException(username + ": not found"); }
@@ -608,7 +608,7 @@ public final class LoanProductDataValidator {
final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue()).value(incomeFromRecoveryAccountId)
.notNull().integerGreaterThanZero();
.ignoreIfNull().integerGreaterThanZero();
final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element);