Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ protected void storeMap(Map<String, String> map) {
map.put("desc", description);
map.put("spbill_create_ip", spbillCreateIp);
map.put("scene", scene);
map.put("brand_id", brandId.toString());
if (brandId != null) {
map.put("brand_id", brandId.toString());
}
map.put("finder_template_id", finderTemplateId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import org.testng.annotations.Test;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

/**
* .
*
Expand All @@ -14,4 +18,32 @@ public class EntPayRequestTest {
public void testToString() {
System.out.println(EntPayRequest.newBuilder().mchId("123").build().toString());
}

/**
* 测试 brandId 为 null 时,getSignParams() 不抛出 NullPointerException.
*/
@Test
public void testGetSignParamsWithNullBrandId() {
EntPayRequest request = EntPayRequest.newBuilder()
.mchId("123")
.amount(100)
.brandId(null)
.build();
Map<String, String> params = request.getSignParams();
assertThat(params).doesNotContainKey("brand_id");
}

/**
* 测试 brandId 不为 null 时,getSignParams() 正确包含 brand_id.
*/
@Test
public void testGetSignParamsWithNonNullBrandId() {
EntPayRequest request = EntPayRequest.newBuilder()
.mchId("123")
.amount(100)
.brandId(1234)
.build();
Map<String, String> params = request.getSignParams();
assertThat(params).containsEntry("brand_id", "1234");
}
}