Cover delete calls
@@ -8,7 +8,9 @@ import org.junit.Test;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
import java.util.Base64;
+import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*;
@@ -81,7 +83,6 @@ public class TransactionResourceTest {
verify(transactionManager).send(any(SendRequest.class));
-
}
@Test
@@ -96,6 +97,7 @@ public class TransactionResourceTest {
verify(transactionManager).send(any(SendRequest.class));
}
+
@Test
public void sendRawEmptyRecipients() throws UnsupportedEncodingException {
@@ -108,6 +110,7 @@ public class TransactionResourceTest {
verify(transactionManager).send(any(SendRequest.class));
}
+
@Test
public void sendRawNullRecipient() throws UnsupportedEncodingException {
@@ -120,4 +123,38 @@ public class TransactionResourceTest {
verify(transactionManager).send(any(SendRequest.class));
}
+
+ @Test
+ public void deleteKey() {
+
+ List<DeleteRequest> results = new ArrayList<>();
+ doAnswer((iom) -> results.add(iom.getArgument(0)))
+ .when(transactionManager).delete(any(DeleteRequest.class));
+
+ Response response = transactionResource.deleteKey("KEY");
+
+ assertThat(results)
+ .hasSize(1)
+ .extracting(DeleteRequest::getKey)
+ .containsExactly("KEY");
+
+ assertThat(response.getStatus()).isEqualTo(204);
+
+ verify(transactionManager).delete(any(DeleteRequest.class));
+
+ }
+
+ @Test
+ public void delete() {
+
+ DeleteRequest deleteRequest = new DeleteRequest();
+ deleteRequest.setKey("KEY");
+
+ Response response = transactionResource.delete(deleteRequest);
+
+ assertThat(response.getStatus()).isEqualTo(200);
+
+ verify(transactionManager).delete(deleteRequest);
+
+ }
}
