Skip to content

Commit

Permalink
Refactor environment status check logic
Browse files Browse the repository at this point in the history
#deploy-test-dolly-backend

Simplify logic by removing dependency on ArrayUtils and using Java Streams to match environments and status. This improves code readability and maintainability.
  • Loading branch information
krharum committed Sep 16, 2024
1 parent 956abcf commit 364cfbc
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import no.nav.dolly.repository.BrukerRepository;
import no.nav.dolly.repository.OrganisasjonBestillingRepository;
import no.nav.testnav.libs.servletsecurity.action.GetUserInfo;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Flux;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -251,10 +251,11 @@ private void updateBestilling(OrganisasjonBestilling bestilling, List<OrgStatus>
bestilling.setFeil(feil);

var ferdig = orgStatus.stream()
.filter(o -> ArrayUtils.contains(bestilling.getMiljoer().split(","), o.getEnvironment()))
.allMatch(o -> DEPLOY_ENDED_STATUS_LIST.stream()
.anyMatch(status -> status.equals(o.getStatus())) &&
ArrayUtils.contains(bestilling.getMiljoer().split(","), o.getEnvironment()));
.anyMatch(status -> status.equals(o.getStatus()))) &&
Arrays.stream(bestilling.getMiljoer().split(","))
.allMatch(miljoe -> orgStatus.stream()
.anyMatch(o -> o.getEnvironment().equals(miljoe)));

bestilling.setFerdig(ferdig);
bestilling.setSistOppdatert(now());
Expand Down

0 comments on commit 364cfbc

Please sign in to comment.