balance-service Sdf16ValidationRule добавил логи, тк. по bic не ищет, но не понял почему
This commit is contained in:
parent
c4e6cb142d
commit
a0d6bc2025
2 changed files with 49 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package ru.spcex.clearing.balance.validation;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf16;
|
||||
|
|
@ -33,11 +35,14 @@ public enum Sdf16ValidationRule implements IValidationRule<ImdgValidationContext
|
|||
sql += String.format("(companySymbolValue = '%s' and companySymbol = '%s') ",
|
||||
bicStr, CompanySymbol.BIC.getKey());
|
||||
}
|
||||
Logger log = LoggerFactory.getLogger(getClass());
|
||||
log.debug("SQL for search company by sdf16: {}", sql);
|
||||
if (sql.isEmpty()) {
|
||||
return of(BalanceError.CompanyNotFound, "inn and bic is empty");
|
||||
}
|
||||
Company company = null;
|
||||
CompanySymbols companySymbols = companySymbolsImdg.getSingleObjectBySQL(sql);
|
||||
log.debug("By sdf16 found companySymbol: {}", companySymbols == null ? null : companySymbols.getId());
|
||||
if (companySymbols != null) {
|
||||
company = companyImdg.getSingleObjectByID(companySymbols.getCompanyId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.balance.validation;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf16;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class Sdf16ValidationRuleTest {
|
||||
|
||||
@Test
|
||||
void values() {
|
||||
ImdgValidationContext<SDf16> ctx = new ImdgValidationContext<>();
|
||||
SDf16 object = new SDf16();
|
||||
// object.setBic(BigDecimal.valueOf(1000004L));
|
||||
object.setInn(BigDecimal.valueOf(1000024L));
|
||||
ctx.setValidatedObject(object);
|
||||
ctx.addImdg(IMDGDistributedNames.Map_CompanySymbols, makeTestMap());
|
||||
ctx.addImdg(IMDGDistributedNames.Map_Company, makeTestMap());
|
||||
Optional<EnumMessage> err = Sdf16ValidationRule.CompanyPresent.validate(ctx);
|
||||
assertTrue(err.isPresent());
|
||||
}
|
||||
|
||||
<T extends SpcexObjectBase> Imdg<T> makeTestMap() {
|
||||
return new Imdg<T>() {
|
||||
@Override
|
||||
public String getMapName() {
|
||||
return Imdg.super.getMapName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getSingleObjectBySQL(String sql) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue