Test #1

Merged
admin merged 1726 commits from test into main 2026-09-17 11:52:45 +08:00
4 changed files with 36 additions and 7 deletions
Showing only changes of commit dceec6cbed - Show all commits
@@ -16,8 +16,8 @@ public interface OverseasQuoteMapper extends BaseMapper<OverseasQuote> {
@Select("""
SELECT COUNT(*) FROM ll_overseas_quote
WHERE warehouse_id=#{warehouseId} AND provider_name=#{providerName} AND currency=#{currency}
AND status='ACTIVE' AND id&lt;&gt;#{excludedId}
AND effective_start&lt;=#{effectiveEnd} AND effective_end&gt;=#{effectiveStart}
AND status='ACTIVE' AND id<>#{excludedId}
AND effective_start<=#{effectiveEnd} AND effective_end>=#{effectiveStart}
""")
int countActiveOverlap(@Param("warehouseId") long warehouseId,
@Param("providerName") String providerName,
@@ -39,7 +39,7 @@ class InboundPlanControllerTest {
void platformPageAllowsAllCustomersWhenCustomerIdIsOmitted() {
InboundPlanRequests.Query query = new InboundPlanRequests.Query(1, 20, null, null, null,
null, null, null, null, null, null, null, null);
when(service.page("100", query)).thenReturn(new PageResult<>(List.of(), 1, 20, 0, 0));
when(service.page(null, query)).thenReturn(new PageResult<>(List.of(), 1, 20, 0, 0));
controller.page(platform(), null, query);
@@ -5,9 +5,13 @@ import com.baiyue.lastleg.masterdata.quote.entity.OverseasQuote;
import com.baiyue.lastleg.masterdata.quote.mapper.OverseasQuoteMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.apache.ibatis.annotations.Select;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.server.ResponseStatusException;
import java.lang.reflect.Method;
import java.time.LocalDate;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -36,4 +40,18 @@ class OverseasQuoteServiceTest {
.isInstanceOf(ResponseStatusException.class)
.hasMessageContaining("409 CONFLICT");
}
@Test
void overlapQueryUsesExecutableSqlOperators() throws NoSuchMethodException {
Method method = OverseasQuoteMapper.class.getDeclaredMethod("countActiveOverlap",
long.class, String.class, String.class, LocalDate.class, LocalDate.class, long.class);
String sql = String.join(" ", method.getAnnotation(Select.class).value());
org.assertj.core.api.Assertions.assertThat(sql)
.contains("id<>#{excludedId}")
.contains("effective_start<=#{effectiveEnd}")
.contains("effective_end>=#{effectiveStart}")
.doesNotContain("&lt;")
.doesNotContain("&gt;");
}
}
@@ -32,6 +32,15 @@ async function safeCleanup(context, name, action) {
}
}
async function continueLifecycle(context, name, action) {
try {
await action()
} catch (error) {
context.assert(MODULE, `${name}生命周期执行`, null, false,
error instanceof Error ? error.message : String(error), BLOCKER)
}
}
function warehousePayload(marker, edited = false) {
const suffix = marker.replace(/[^A-Za-z0-9]/g, '').slice(-20).toUpperCase()
return {
@@ -350,10 +359,12 @@ export async function run(context) {
const resource = { marker: context.marker }
context.createdResources.phase4OverseasMasterData = resource
try {
await createAndVerifyPartnerWarehouse(context, resource)
await quoteLifecycle(context, resource)
await exchangeLifecycle(context, resource)
await vehicleLifecycle(context, resource)
await continueLifecycle(context, '海外报价', async () => {
await createAndVerifyPartnerWarehouse(context, resource)
await quoteLifecycle(context, resource)
})
await continueLifecycle(context, '月度汇率', () => exchangeLifecycle(context, resource))
await continueLifecycle(context, '车辆主数据', () => vehicleLifecycle(context, resource))
} finally {
await safeCleanup(context, '海外报价', async () => {
if (!resource.quote?.id) return