@Test public void itFiltersByAccountIdIfGiven() throws Exception { when(repository.listClusters("1", null)).thenReturn(asList(cluster("1", "alpha"))); ListClustersResponse response = api.listClusters(ListClustersRequest.builder().accountId("1").build()); assertThat(response.getClusters()) .extracting("accountId", "clusterName") .containsExactly(tuple("1", "alpha")); }
@Test public void itFiltersByAccountIdAndPrefixIfGiven() throws Exception { when(repository.listClusters("1", "alpha")) .thenReturn(asList(cluster("1", "alpha-one"), cluster("1", "alpha-two"))); ListClustersResponse response = api.listClusters( ListClustersRequest.builder().accountId("1").clusterNamePrefix("alpha").build()); assertThat(response.getClusters()) .extracting("accountId", "clusterName") .containsExactlyInAnyOrder(tuple("1", "alpha-one"), tuple("1", "alpha-two")); } }
public ListClustersRequestBuilder listClustersRequest() { return ListClustersRequest.builder().accountId(accountId).clusterNamePrefix(clusterName); }