|
69 | 69 | import static redis_request.RedisRequestOuterClass.RequestType.Type; |
70 | 70 | import static redis_request.RedisRequestOuterClass.RequestType.Unlink; |
71 | 71 | import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax; |
| 72 | +import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin; |
72 | 73 | import static redis_request.RedisRequestOuterClass.RequestType.ZScore; |
73 | 74 | import static redis_request.RedisRequestOuterClass.RequestType.Zadd; |
74 | 75 | import static redis_request.RedisRequestOuterClass.RequestType.Zcard; |
@@ -1790,6 +1791,55 @@ public void zcard_returns_success() { |
1790 | 1791 | assertEquals(value, payload); |
1791 | 1792 | } |
1792 | 1793 |
|
| 1794 | + @SneakyThrows |
| 1795 | + @Test |
| 1796 | + public void zpopmin_returns_success() { |
| 1797 | + // setup |
| 1798 | + String key = "testKey"; |
| 1799 | + String[] arguments = new String[] {key}; |
| 1800 | + Map<String, Double> value = Map.of("member1", 2.5); |
| 1801 | + |
| 1802 | + CompletableFuture<Map<String, Double>> testResponse = new CompletableFuture<>(); |
| 1803 | + testResponse.complete(value); |
| 1804 | + |
| 1805 | + // match on protobuf request |
| 1806 | + when(commandManager.<Map<String, Double>>submitNewCommand(eq(ZPopMin), eq(arguments), any())) |
| 1807 | + .thenReturn(testResponse); |
| 1808 | + |
| 1809 | + // exercise |
| 1810 | + CompletableFuture<Map<String, Double>> response = service.zpopmin(key); |
| 1811 | + Map<String, Double> payload = response.get(); |
| 1812 | + |
| 1813 | + // verify |
| 1814 | + assertEquals(testResponse, response); |
| 1815 | + assertEquals(value, payload); |
| 1816 | + } |
| 1817 | + |
| 1818 | + @SneakyThrows |
| 1819 | + @Test |
| 1820 | + public void zpopmin_with_count_returns_success() { |
| 1821 | + // setup |
| 1822 | + String key = "testKey"; |
| 1823 | + long count = 2L; |
| 1824 | + String[] arguments = new String[] {key, Long.toString(count)}; |
| 1825 | + Map<String, Double> value = Map.of("member1", 2.0, "member2", 3.0); |
| 1826 | + |
| 1827 | + CompletableFuture<Map<String, Double>> testResponse = new CompletableFuture<>(); |
| 1828 | + testResponse.complete(value); |
| 1829 | + |
| 1830 | + // match on protobuf request |
| 1831 | + when(commandManager.<Map<String, Double>>submitNewCommand(eq(ZPopMin), eq(arguments), any())) |
| 1832 | + .thenReturn(testResponse); |
| 1833 | + |
| 1834 | + // exercise |
| 1835 | + CompletableFuture<Map<String, Double>> response = service.zpopmin(key, count); |
| 1836 | + Map<String, Double> payload = response.get(); |
| 1837 | + |
| 1838 | + // verify |
| 1839 | + assertEquals(testResponse, response); |
| 1840 | + assertEquals(value, payload); |
| 1841 | + } |
| 1842 | + |
1793 | 1843 | @SneakyThrows |
1794 | 1844 | @Test |
1795 | 1845 | public void zpopmax_returns_success() { |
|
0 commit comments