-
Notifications
You must be signed in to change notification settings - Fork 16
AIML-322: Add environments, statuses, and severities filters to LibraryFilterForm #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ChrisEdwards
merged 5 commits into
main
from
AIML-322-add-library-filter-form-enhancements
Jan 5, 2026
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0adbfbc
Add environments filter to LibraryFilterForm
ChrisEdwards 076523d
Add statuses filter to LibraryFilterForm
ChrisEdwards 4f8e349
Add severities filter to LibraryFilterForm
ChrisEdwards 2838ef1
Improve test assertions per PR review feedback
ChrisEdwards d7a2dde
Update license headers to 2026
ChrisEdwards File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
154 changes: 154 additions & 0 deletions
154
sdk/src/test/java/com/contrastsecurity/http/LibraryFilterFormTest.java
This file contains hidden or 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,154 @@ | ||
| package com.contrastsecurity.http; | ||
|
|
||
| /*- | ||
| * #%L | ||
| * Contrast Java SDK | ||
| * %% | ||
| * Copyright (C) 2022 - 2025 Contrast Security, Inc. | ||
| * %% | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * #L% | ||
| */ | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.EnumSet; | ||
| import java.util.List; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| final class LibraryFilterFormTest { | ||
|
|
||
| LibraryFilterForm form; | ||
|
|
||
| @BeforeEach | ||
| public void setUp() { | ||
| form = new LibraryFilterForm(); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_include_environments_when_set() { | ||
| form.setEnvironments(EnumSet.of(ServerEnvironment.DEVELOPMENT, ServerEnvironment.PRODUCTION)); | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).contains("environments="); | ||
| assertThat(qs).contains("DEVELOPMENT"); | ||
| assertThat(qs).contains("PRODUCTION"); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_not_include_environments_when_empty() { | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).doesNotContain("environments="); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_include_single_environment() { | ||
| form.setEnvironments(EnumSet.of(ServerEnvironment.QA)); | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).contains("environments=QA"); | ||
| } | ||
|
|
||
| @Test | ||
| public void getEnvironments_should_return_set_environments() { | ||
| EnumSet<ServerEnvironment> expected = | ||
| EnumSet.of(ServerEnvironment.DEVELOPMENT, ServerEnvironment.QA); | ||
| form.setEnvironments(expected); | ||
|
|
||
| assertThat(form.getEnvironments()).isEqualTo(expected); | ||
| } | ||
|
|
||
| @Test | ||
| public void environments_should_be_empty_by_default() { | ||
| assertThat(form.getEnvironments()).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_include_statuses_when_set() { | ||
| form.setStatuses(Arrays.asList("CURRENT", "FLAGGED")); | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).contains("statuses="); | ||
| assertThat(qs).contains("CURRENT"); | ||
| assertThat(qs).contains("FLAGGED"); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_not_include_statuses_when_empty() { | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).doesNotContain("statuses="); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_include_single_status() { | ||
| form.setStatuses(Arrays.asList("STALE")); | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).contains("statuses=STALE"); | ||
| } | ||
|
|
||
| @Test | ||
| public void getStatuses_should_return_set_statuses() { | ||
| List<String> expected = Arrays.asList("CURRENT", "UNKNOWN"); | ||
| form.setStatuses(expected); | ||
|
|
||
| assertThat(form.getStatuses()).isEqualTo(expected); | ||
| } | ||
|
|
||
| @Test | ||
| public void statuses_should_be_empty_by_default() { | ||
| assertThat(form.getStatuses()).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_include_severities_when_set() { | ||
| form.setSeverities(Arrays.asList("CRITICAL", "HIGH")); | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).contains("severities="); | ||
| assertThat(qs).contains("CRITICAL"); | ||
| assertThat(qs).contains("HIGH"); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_not_include_severities_when_empty() { | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).doesNotContain("severities="); | ||
| } | ||
|
|
||
| @Test | ||
| public void toString_should_include_single_severity() { | ||
| form.setSeverities(Arrays.asList("MEDIUM")); | ||
| String qs = form.toString(); | ||
|
|
||
| assertThat(qs).contains("severities=MEDIUM"); | ||
| } | ||
|
|
||
| @Test | ||
| public void getSeverities_should_return_set_severities() { | ||
| List<String> expected = Arrays.asList("LOW", "NOTE"); | ||
| form.setSeverities(expected); | ||
|
|
||
| assertThat(form.getSeverities()).isEqualTo(expected); | ||
| } | ||
|
|
||
| @Test | ||
| public void severities_should_be_empty_by_default() { | ||
| assertThat(form.getSeverities()).isEmpty(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.