|
| 1 | +package pl.smsapi.api.action.hlr; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | +import pl.smsapi.api.action.sms.StatusJsonMother; |
| 5 | +import pl.smsapi.exception.SmsapiException; |
| 6 | +import pl.smsapi.test.doubles.ClientStub; |
| 7 | +import pl.smsapi.test.doubles.ProxyRequestSpy; |
| 8 | + |
| 9 | +import java.util.HashMap; |
| 10 | + |
| 11 | +import static org.junit.Assert.assertEquals; |
| 12 | + |
| 13 | +public class HLRCheckNumberTest { |
| 14 | + |
| 15 | + @Test |
| 16 | + public void executeCheckNumberRequest() throws SmsapiException { |
| 17 | + ProxyRequestSpy requestStub = new ProxyRequestSpy(StatusJsonMother.create()); |
| 18 | + HLRCheckNumber action = new HLRCheckNumber("500600700"); |
| 19 | + action.client(new ClientStub()); |
| 20 | + action.proxy(requestStub); |
| 21 | + |
| 22 | + action.execute(); |
| 23 | + |
| 24 | + assertEquals("POST", requestStub.requestMethod); |
| 25 | + assertEquals("hlrsync.do", requestStub.requestEndpoint); |
| 26 | + HashMap<String, String> expectedRequestPayload = new HashMap<>(); |
| 27 | + expectedRequestPayload.put("number", "500600700"); |
| 28 | + expectedRequestPayload.put("format", "json"); |
| 29 | + assertEquals(expectedRequestPayload, requestStub.requestPayload); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void executeCheckNumberWithOptionalFieldsRequest() throws SmsapiException { |
| 34 | + ProxyRequestSpy requestStub = new ProxyRequestSpy(StatusJsonMother.create()); |
| 35 | + HLRCheckNumber action = new HLRCheckNumber("500600700"); |
| 36 | + action.client(new ClientStub()); |
| 37 | + action.proxy(requestStub); |
| 38 | + action.setIDx("example-user-provided-id-123"); |
| 39 | + |
| 40 | + action.execute(); |
| 41 | + |
| 42 | + assertEquals("POST", requestStub.requestMethod); |
| 43 | + assertEquals("hlrsync.do", requestStub.requestEndpoint); |
| 44 | + HashMap<String, String> expectedRequestPayload = new HashMap<>(); |
| 45 | + expectedRequestPayload.put("number", "500600700"); |
| 46 | + expectedRequestPayload.put("format", "json"); |
| 47 | + expectedRequestPayload.put("idx", "example-user-provided-id-123"); |
| 48 | + assertEquals(expectedRequestPayload, requestStub.requestPayload); |
| 49 | + } |
| 50 | +} |
0 commit comments