Skip to content

Commit

Permalink
[backend] clean
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 committed Oct 16, 2024
1 parent dc621c3 commit dba6676
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions openbas-api/src/main/java/io/openbas/utils/AtomicTestingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import io.openbas.atomic_testing.TargetType;
import io.openbas.database.model.*;
import io.openbas.database.model.InjectExpectation.EXPECTATION_TYPE;
import io.openbas.database.raw.RawAsset;
import io.openbas.database.raw.RawAssetGroup;
import io.openbas.database.raw.RawInjectExpectation;
import io.openbas.database.raw.RawTeam;
import io.openbas.database.raw.*;
import io.openbas.expectation.ExpectationType;
import io.openbas.rest.atomic_testing.form.InjectTargetWithResult;
import io.openbas.utils.AtomicTestingMapper.ExpectationResultsByType;
Expand Down Expand Up @@ -297,6 +294,7 @@ public static List<InjectTargetWithResult> getTargetsWithResults(Inject inject)
public static List<InjectTargetWithResult> getTargetsWithResultsFromRaw(
List<RawInjectExpectation> expectations,
Map<String, RawTeam> rawTeamMap,
Map<String, RawUser> rawUserMap,
Map<String, RawAsset> rawAssetMap,
Map<String, RawAssetGroup> rawAssetGroupMap,
Map<String, List<Endpoint>> dynamicAssetGroupMap
Expand Down Expand Up @@ -483,9 +481,9 @@ public static List<InjectTargetWithResult> getTargetsWithResultsFromRaw(
)
.entrySet().stream()
.map(entry -> new InjectTargetWithResult(TargetType.TEAMS, entry.getKey(),
rawTeamMap.get(teamExpectationMap.get(entry.getKey())).getTeam_name(), entry.getValue(),
rawTeamMap.get(teamExpectationMap.get(entry.getKey()).getTeam_id()).getTeam_name(), entry.getValue(),
playerExpectations.isEmpty() ? List.of()
: calculateResultsforPlayersFromRaw(groupedByTeamAndUser.get(entry.getKey())), null))
: calculateResultsforPlayersFromRaw(groupedByTeamAndUser.get(entry.getKey()), rawUserMap), null))
.toList()
);
}
Expand All @@ -504,7 +502,7 @@ public static List<InjectTargetWithResult> getTargetsWithResultsFromRaw(
)
.entrySet().stream()
.map(entry -> new InjectTargetWithResult(TargetType.ASSETS, entry.getKey(),
rawAssetMap.get(assetExpectationMap.get(entry.getKey())).getAsset_name(), entry.getValue(),
rawAssetMap.get(assetExpectationMap.get(entry.getKey()).getAsset_id()).getAsset_name(), entry.getValue(),
Objects.equals(rawAssetMap.get(entry.getKey()).getAsset_type(), "Endpoint")
? Endpoint.PLATFORM_TYPE.valueOf(rawAssetMap.get(entry.getKey()).getEndpoint_platform()) : null))
.toList()
Expand Down Expand Up @@ -546,7 +544,7 @@ public static List<InjectTargetWithResult> getTargetsWithResultsFromRaw(
}

// Other children without expectations are added with a default result
rawAssetGroupMap.get(assetGroupExpectationMap.get(entry.getKey())).getAsset_ids().forEach(asset -> {
rawAssetGroupMap.get(assetGroupExpectationMap.get(entry.getKey()).getAsset_group_id()).getAsset_ids().forEach(asset -> {
boolean foundAssetsWithoutResults = children.stream()
.noneMatch(child -> child.getId().equals(asset));
if (foundAssetsWithoutResults) {
Expand Down Expand Up @@ -582,7 +580,7 @@ public static List<InjectTargetWithResult> getTargetsWithResultsFromRaw(
}

return new InjectTargetWithResult(TargetType.ASSETS_GROUPS, entry.getKey(),
rawAssetGroupMap.get(assetGroupExpectationMap.get(entry.getKey())).getAsset_group_name(), entry.getValue(),
rawAssetGroupMap.get(assetGroupExpectationMap.get(entry.getKey()).getAsset_group_id()).getAsset_group_name(), entry.getValue(),
sortResults(children), null);
})
.toList());
Expand Down Expand Up @@ -615,12 +613,14 @@ private static List<InjectTargetWithResult> calculateResultsforPlayers(
}

private static List<InjectTargetWithResult> calculateResultsforPlayersFromRaw(
Map<String, List<RawInjectExpectation>> expectationsByUser) {
Map<String, List<RawInjectExpectation>> expectationsByUser,
Map<String, RawUser> rawUserMap
) {
return expectationsByUser.entrySet().stream()
.map(userEntry -> new InjectTargetWithResult(
TargetType.PLAYER,
userEntry.getKey(),
"toto",
StringUtils.getName(rawUserMap.get(userEntry.getValue().get(0)).getUser_firstname(), rawUserMap.get(userEntry.getValue().get(0)).getUser_lastname()),
getExpectationResultByTypesFromRaw(userEntry.getValue()),
null
))
Expand Down

0 comments on commit dba6676

Please sign in to comment.