Skip to content

Commit

Permalink
remove repository changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasCAI-mlv committed Aug 6, 2024
1 parent b3afc2f commit 0da2b65
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ public interface ResourceQuotaRepository {
*/
List<ResourceQuota> findAll();

/**
* Get resource quota by namespace.
*
* @param namespace The namespace used to research
* @return The resource quotas associated to the namespace
*/
List<ResourceQuota> findAllForNamespace(String namespace);


/**
* Get resource quota by namespace.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,7 @@ public List<ResourceQuota> findAll() {
}

/**
* Get resource quota by namespace.
*
* @param namespace The namespace used to research
* @return A resource quota
*/
@Override
public List<ResourceQuota> findAllForNamespace(String namespace) {
return getKafkaStore().values()
.stream()
.filter(resourceQuota -> resourceQuota.getMetadata().getNamespace().equals(namespace))
.toList();
}

/**
* Get resource quota by namespace.
* Get resource quota of a given namespace.
*
* @param namespace The namespace used to research
* @return A resource quota
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public Optional<ResourceQuota> findForNamespace(String namespace) {
* @return The researched resource quota
*/
public List<ResourceQuota> findAllForNamespace(String namespace) {
return resourceQuotaRepository.findAllForNamespace(namespace);
return resourceQuotaRepository.findAll()
.stream()
.filter(resourceQuota -> resourceQuota.getMetadata().getNamespace().equals(namespace))
.toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void shouldListQuotasWithoutParameter() {
ResourceQuota resourceQuota1 = ResourceQuota.builder()
.metadata(Metadata.builder()
.cluster("local")
.namespace("namespace")
.name("quotaName")
.build())
.spec(Map.of(COUNT_TOPICS.toString(), "1"))
Expand All @@ -92,12 +93,13 @@ void shouldListQuotasWithoutParameter() {
ResourceQuota resourceQuota2 = ResourceQuota.builder()
.metadata(Metadata.builder()
.cluster("local")
.namespace("namespace")
.name("quotaName2")
.build())
.spec(Map.of(COUNT_TOPICS.toString(), "1"))
.build();

when(resourceQuotaRepository.findAllForNamespace("namespace"))
when(resourceQuotaRepository.findAll())
.thenReturn(List.of(resourceQuota1, resourceQuota2));

assertEquals(List.of(resourceQuota1, resourceQuota2),
Expand All @@ -109,12 +111,13 @@ void shouldListQuotasWithNameParameter() {
ResourceQuota resourceQuota = ResourceQuota.builder()
.metadata(Metadata.builder()
.cluster("local")
.namespace("namespace")
.name("quotaName")
.build())
.spec(Map.of(COUNT_TOPICS.toString(), "1"))
.build();

when(resourceQuotaRepository.findAllForNamespace("namespace"))
when(resourceQuotaRepository.findAll())
.thenReturn(List.of(resourceQuota));

assertEquals(List.of(resourceQuota),
Expand All @@ -128,6 +131,7 @@ void shouldListQuotasWithWildcardNameParameter() {
.metadata(Metadata.builder()
.cluster("local")
.name("quotaName1")
.namespace("namespace")
.build())
.spec(Map.of(COUNT_TOPICS.toString(), "1"))
.build();
Expand All @@ -136,6 +140,7 @@ void shouldListQuotasWithWildcardNameParameter() {
.metadata(Metadata.builder()
.cluster("local")
.name("quotaName2")
.namespace("namespace")
.build())
.spec(Map.of(COUNT_TOPICS.toString(), "1"))
.build();
Expand All @@ -144,11 +149,12 @@ void shouldListQuotasWithWildcardNameParameter() {
.metadata(Metadata.builder()
.cluster("local")
.name("topicQuota2")
.namespace("namespace")
.build())
.spec(Map.of(COUNT_TOPICS.toString(), "1"))
.build();

when(resourceQuotaRepository.findAllForNamespace("namespace"))
when(resourceQuotaRepository.findAll())
.thenReturn(List.of(resourceQuota1, resourceQuota2, resourceQuota3));

assertEquals(List.of(resourceQuota1, resourceQuota2, resourceQuota3),
Expand Down

0 comments on commit 0da2b65

Please sign in to comment.