-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEST]: Improvement: Verification of validation response
- Loading branch information
Yuliia Miroshnychenko
committed
Oct 2, 2024
1 parent
4922be0
commit c1dd3da
Showing
10 changed files
with
108 additions
and
48 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...n/groovy/org/openkilda/functionaltests/helpers/model/ComplexFlowValidationResponse.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.openkilda.functionaltests.helpers.model | ||
|
||
import org.openkilda.northbound.dto.v1.flows.FlowValidationDto | ||
import org.openkilda.northbound.dto.v1.flows.PathDiscrepancyDto | ||
import org.openkilda.northbound.dto.v2.haflows.HaFlowValidationResult | ||
import org.openkilda.northbound.dto.v2.yflows.YFlowValidationResult | ||
|
||
import groovy.transform.ToString | ||
|
||
@ToString | ||
class ComplexFlowValidationResponse { | ||
private static final String COOKIE_ID_IN_RULE_DISCREPANCY_STRING_REGEX = /-?\d{19}/ | ||
|
||
boolean asExpected | ||
List<SubFlowValidationDiscrepancies> subFlowsDiscrepancies | ||
|
||
ComplexFlowValidationResponse(YFlowValidationResult yFlowValidation) { | ||
this.asExpected = yFlowValidation.asExpected | ||
this.subFlowsDiscrepancies = collectDiscrepanciesPerSubFlow(yFlowValidation.subFlowValidationResults) | ||
} | ||
|
||
ComplexFlowValidationResponse(HaFlowValidationResult haFlowValidation) { | ||
this.asExpected = haFlowValidation.asExpected | ||
this.subFlowsDiscrepancies = collectDiscrepanciesPerSubFlow(haFlowValidation.subFlowValidationResults) | ||
|
||
} | ||
|
||
static private List<SubFlowValidationDiscrepancies> collectDiscrepanciesPerSubFlow(List<FlowValidationDto> subFlowValidationDetails) { | ||
List<SubFlowValidationDiscrepancies> discrepanciesPerSubFlow = subFlowValidationDetails.groupBy { it.flowId }.collect{ | ||
HashMap<FlowDirection, List<PathDiscrepancyDto>> discrepancy = [:] | ||
it.value.each { | ||
verifyValidateLogic(it) | ||
it.asExpected ?: discrepancy.put(FlowDirection.getByDirection(it.direction.toLowerCase()), it.discrepancies) | ||
} | ||
discrepancy.isEmpty() ? null : new SubFlowValidationDiscrepancies(subFlowId: it.key, flowDiscrepancies: discrepancy) | ||
|
||
}.findAll() | ||
discrepanciesPerSubFlow | ||
} | ||
|
||
static private void verifyValidateLogic(FlowValidationDto validationDto) { | ||
assert (validationDto.asExpected && validationDto.discrepancies.isEmpty()) || (!validationDto.asExpected && !validationDto.discrepancies.isEmpty()), | ||
"There is an error in the validation logic $validationDto" | ||
} | ||
|
||
Set<Long> retrieveAllRulesCookieFromDiscrepancy() { | ||
def rules = subFlowsDiscrepancies.flowDiscrepancies*.values().flatten() | ||
rules.collect { new Long((it =~ COOKIE_ID_IN_RULE_DISCREPANCY_STRING_REGEX)[0]) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
.../groovy/org/openkilda/functionaltests/helpers/model/SubFlowValidationDiscrepancies.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.openkilda.functionaltests.helpers.model | ||
|
||
import org.openkilda.northbound.dto.v1.flows.PathDiscrepancyDto | ||
|
||
import groovy.transform.ToString | ||
import groovy.transform.TupleConstructor | ||
|
||
@TupleConstructor | ||
@ToString | ||
class SubFlowValidationDiscrepancies { | ||
String subFlowId | ||
Map<FlowDirection, List<PathDiscrepancyDto>> flowDiscrepancies | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters