✨ 按客户区域计算毛利并完善汇总展示
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package com.bms.report;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.price.domain.vo.PrcProfitReportQuery;
|
||||
import com.bms.price.mapper.PrcProfitReportMapper;
|
||||
import com.bms.price.service.impl.PrcProfitReportServiceImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
class ProfitAreaRuleTest
|
||||
{
|
||||
@Test
|
||||
void reportQueriesResolveRuleOnServerAndRejectUnknownAreas()
|
||||
{
|
||||
AtomicInteger calls = new AtomicInteger();
|
||||
PrcProfitReportMapper mapper = (PrcProfitReportMapper) Proxy.newProxyInstance(
|
||||
getClass().getClassLoader(), new Class<?>[] { PrcProfitReportMapper.class },
|
||||
(proxy, method, args) -> {
|
||||
calls.incrementAndGet();
|
||||
return Collections.emptyList();
|
||||
});
|
||||
PrcProfitReportServiceImpl service = new PrcProfitReportServiceImpl();
|
||||
ReflectionTestUtils.setField(service, "profitReportMapper", mapper);
|
||||
|
||||
PrcProfitReportQuery query = new PrcProfitReportQuery();
|
||||
query.setCustomerArea(" GZ ");
|
||||
query.setProfitRule("SHENZHEN");
|
||||
service.selectSummary(query);
|
||||
assertEquals("GZ", query.getCustomerArea());
|
||||
assertEquals("GUANGZHOU", query.getProfitRule());
|
||||
|
||||
query.setCustomerArea("C");
|
||||
query.setProfitRule("GUANGZHOU");
|
||||
service.selectOrderRows(query);
|
||||
assertEquals("SHENZHEN", query.getProfitRule());
|
||||
service.selectProductRows(query);
|
||||
assertEquals(3, calls.get());
|
||||
|
||||
query.setCustomerArea("UNKNOWN");
|
||||
assertThrows(ServiceException.class, () -> service.selectProductRows(query));
|
||||
query.setCustomerArea("");
|
||||
assertThrows(ServiceException.class, () -> service.selectSummary(query));
|
||||
assertEquals(3, calls.get());
|
||||
assertEquals("SHENZHEN", service.selectAreaRules().get("C"));
|
||||
assertEquals("GUANGZHOU", service.selectAreaRules().get("GZ"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user