|
| 1 | +package pl.smsapi.api.action.sms; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | +import pl.smsapi.exception.SmsapiException; |
| 5 | +import pl.smsapi.test.doubles.ClientStub; |
| 6 | +import pl.smsapi.test.doubles.ProxyRequestSpy; |
| 7 | + |
| 8 | +import java.util.HashMap; |
| 9 | + |
| 10 | +import static org.junit.Assert.assertEquals; |
| 11 | + |
| 12 | +public class SMSGetTest { |
| 13 | + |
| 14 | + @Test |
| 15 | + public void executeGetSmsRequest() throws SmsapiException { |
| 16 | + ProxyRequestSpy requestStub = new ProxyRequestSpy(StatusJsonMother.create()); |
| 17 | + SMSGet action = new SMSGet("0f0f0f0f0f0f0f0f0f0f0f0f"); |
| 18 | + action.client(new ClientStub()); |
| 19 | + action.proxy(requestStub); |
| 20 | + |
| 21 | + action.execute(); |
| 22 | + |
| 23 | + assertEquals("POST", requestStub.requestMethod); |
| 24 | + assertEquals("sms.do", requestStub.requestEndpoint); |
| 25 | + HashMap<String, String> expectedRequestPayload = new HashMap<>(); |
| 26 | + expectedRequestPayload.put("status", "0f0f0f0f0f0f0f0f0f0f0f0f"); |
| 27 | + expectedRequestPayload.put("format", "json"); |
| 28 | + assertEquals(expectedRequestPayload, requestStub.requestPayload); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void executeGetMultipleSmsRequest() throws SmsapiException { |
| 33 | + ProxyRequestSpy requestStub = new ProxyRequestSpy(StatusJsonMother.create()); |
| 34 | + SMSGet action = new SMSGet(new String[]{"0f0f0f0f0f0f0f0f0f0f0f0f", "0f0f0f0f0f0f0f0f0f0f0f01"}); |
| 35 | + action.client(new ClientStub()); |
| 36 | + action.proxy(requestStub); |
| 37 | + |
| 38 | + action.execute(); |
| 39 | + |
| 40 | + assertEquals("POST", requestStub.requestMethod); |
| 41 | + assertEquals("sms.do", requestStub.requestEndpoint); |
| 42 | + HashMap<String, String> expectedRequestPayload = new HashMap<>(); |
| 43 | + expectedRequestPayload.put("status", "0f0f0f0f0f0f0f0f0f0f0f0f|0f0f0f0f0f0f0f0f0f0f0f01"); |
| 44 | + expectedRequestPayload.put("format", "json"); |
| 45 | + assertEquals(expectedRequestPayload, requestStub.requestPayload); |
| 46 | + } |
| 47 | +} |
0 commit comments