Skip to content

Commit

Permalink
Merge branch 'main' into RISDEV-5883_add_duplicate_check
Browse files Browse the repository at this point in the history
  • Loading branch information
anne-ds committed Dec 18, 2024
2 parents 867cabe + c01c3f6 commit c9a12d1
Show file tree
Hide file tree
Showing 27 changed files with 159 additions and 121 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/backend-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
java-version: "21.0"
distribution: "temurin"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@3839b20885c2c3507be5f0521853826f4b37038a
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6
with:
gradle-version: ${{ env.GRADLE_VERSION}}
- name: Run backend tests
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
java-version: "21.0"
distribution: "temurin"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@3839b20885c2c3507be5f0521853826f4b37038a
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Run backend tests
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
- name: Setup Gradle
uses: gradle/actions/setup-gradle@3839b20885c2c3507be5f0521853826f4b37038a
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6
with:
gradle-version: ${{ env.GRADLE_VERSION }}
- name: Scan with SonarQube
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ jobs:
permissions:
id-token: write # Enable OIDC for gitsign
steps:
- uses: chainguard-dev/actions/setup-gitsign@906ed9cc1377f6d67967f35308628f8845ee065f
- uses: chainguard-dev/actions/setup-gitsign@0c26ac0ebfc8e53f8c2debe657cc2c5f6fe26663
- name: Deploy new images
uses: digitalservicebund/argocd-deploy@4fac1bb67c92ed168f6d9b22f8779ce241a9e412 # v1.0.0
with:
Expand Down Expand Up @@ -601,7 +601,7 @@ jobs:
permissions:
id-token: write # Enable OIDC for gitsign
steps:
- uses: chainguard-dev/actions/setup-gitsign@906ed9cc1377f6d67967f35308628f8845ee065f
- uses: chainguard-dev/actions/setup-gitsign@0c26ac0ebfc8e53f8c2debe657cc2c5f6fe26663
- name: Deploy new images
uses: digitalservicebund/argocd-deploy@4fac1bb67c92ed168f6d9b22f8779ce241a9e412 # v1.0.0
with:
Expand Down Expand Up @@ -643,7 +643,7 @@ jobs:
permissions:
id-token: write # Enable OIDC for gitsign
steps:
- uses: chainguard-dev/actions/setup-gitsign@906ed9cc1377f6d67967f35308628f8845ee065f
- uses: chainguard-dev/actions/setup-gitsign@0c26ac0ebfc8e53f8c2debe657cc2c5f6fe26663
- name: Deploy new images
uses: digitalservicebund/argocd-deploy@4fac1bb67c92ed168f6d9b22f8779ce241a9e412 # v1.0.0
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public CourtController(CourtService service) {
*/
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public List<Court> getCourts(@RequestParam(value = "q", required = false) String searchStr) {
return service.getCourts(searchStr);
public List<Court> getCourts(
@RequestParam(value = "q", required = false) String searchStr,
@RequestParam(value = "sz", required = false, defaultValue = "200") Integer size) {
return service.getCourts(searchStr, size);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ label LIKE UPPER('%' || :searchStr || '%')
ORDER BY
weight,
label
LIMIT 10
LIMIT :size
""")
List<CourtDTO> findBySearchStr(@Param("searchStr") String searchStr);
List<CourtDTO> findBySearchStr(@Param("searchStr") String searchStr, @Param("size") Integer size);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.bund.digitalservice.ris.caselaw.adapter.database.jpa;

import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -20,5 +19,5 @@ OR LOWER(ct.title) LIKE COALESCE(concat(LOWER(:searchStr), '%'), '%'))
ORDER BY ct.abbreviation
LIMIT 15
""")
List<LegalPeriodicalDTO> findBySearchStr(@Param("searchStr") Optional<String> searchStr);
List<LegalPeriodicalDTO> findBySearchStr(@Param("searchStr") String searchStr);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public PostgresCourtRepositoryImpl(DatabaseCourtRepository repository) {
}

@Override
public List<Court> findBySearchStr(String searchString) {
return repository.findBySearchStr(searchString).stream()
public List<Court> findBySearchStr(String searchString, Integer size) {
return repository.findBySearchStr(searchString, size).stream()
.map(CourtTransformer::transformToDomain)
.toList();
}
Expand Down Expand Up @@ -48,8 +48,8 @@ public Optional<Court> findUniqueBySearchString(String searchString) {
}

@Override
public List<Court> findAllByOrderByTypeAscLocationAsc() {
return repository.findByOrderByTypeAscLocationAsc(Limit.of(10)).stream()
public List<Court> findAllByOrderByTypeAscLocationAsc(Integer size) {
return repository.findByOrderByTypeAscLocationAsc(Limit.of(size)).stream()
.map(CourtTransformer::transformToDomain)
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import de.bund.digitalservice.ris.caselaw.domain.LegalPeriodicalRepository;
import de.bund.digitalservice.ris.caselaw.domain.lookuptable.LegalPeriodical;
import java.util.List;
import java.util.Optional;
import org.springframework.stereotype.Repository;

@Repository
Expand All @@ -16,7 +15,7 @@ public PostgresLegalPeriodicalRepositoryImpl(DatabaseLegalPeriodicalRepository r
}

@Override
public List<LegalPeriodical> findAllBySearchStr(Optional<String> searchStr) {
public List<LegalPeriodical> findAllBySearchStr(String searchStr) {
return repository.findBySearchStr(searchStr).stream()
.map(LegalPeriodicalTransformer::transformToDomain)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public CourtService(CourtRepository courtRepository) {
this.courtRepository = courtRepository;
}

public List<Court> getCourts(String searchStr) {
public List<Court> getCourts(String searchStr, Integer size) {
if (searchStr != null && !searchStr.trim().isBlank()) {
return courtRepository.findBySearchStr(searchStr.trim());
return courtRepository.findBySearchStr(searchStr.trim(), size);
}

return courtRepository.findAllByOrderByTypeAscLocationAsc();
return courtRepository.findAllByOrderByTypeAscLocationAsc(size);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import de.bund.digitalservice.ris.caselaw.domain.lookuptable.LegalPeriodical;
import java.util.List;
import java.util.Optional;
import org.springframework.data.repository.NoRepositoryBean;

/** Domain repository for legal periodicals */
Expand All @@ -15,5 +14,5 @@ public interface LegalPeriodicalRepository {
* @return list of legal periodical which contain the search string or the whole list of legal
* periodical if no search string is given
*/
List<LegalPeriodical> findAllBySearchStr(Optional<String> searchStr);
List<LegalPeriodical> findAllBySearchStr(String searchStr);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public LegalPeriodicalService(LegalPeriodicalRepository legalPeriodicalRepositor
* periodical if no search string is given
*/
public List<LegalPeriodical> getLegalPeriodicals(Optional<String> searchStr) {
return legalPeriodicalRepository.findAllBySearchStr(searchStr.map(String::trim));
return legalPeriodicalRepository.findAllBySearchStr(searchStr.map(String::trim).orElse(null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

@NoRepositoryBean
public interface CourtRepository {
List<Court> findBySearchStr(String searchString);
List<Court> findBySearchStr(String searchString, Integer size);

Optional<Court> findByTypeAndLocation(String type, String location);

Optional<Court> findUniqueBySearchString(String searchString);

List<Court> findAllByOrderByTypeAscLocationAsc();
List<Court> findAllByOrderByTypeAscLocationAsc(Integer size);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.bund.digitalservice.ris.caselaw.adapter;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -28,8 +30,8 @@ class CourtControllerTest {
@MockBean private ClientRegistrationRepository clientRegistrationRepository;

@Test
void testGetCourts() {
when(service.getCourts(null)).thenReturn(new ArrayList<>());
void testGetCourtsWithoutSize() {
when(service.getCourts(anyString(), anyInt())).thenReturn(new ArrayList<>());

risWebTestClient
.withDefaultLogin()
Expand All @@ -39,6 +41,36 @@ void testGetCourts() {
.expectStatus()
.isOk();

verify(service, times(1)).getCourts(null);
verify(service, times(1)).getCourts(null, 200);
}

@Test
void testGetCourtsWithSize() {
when(service.getCourts(anyString(), anyInt())).thenReturn(new ArrayList<>());

risWebTestClient
.withDefaultLogin()
.get()
.uri("/api/v1/caselaw/courts?sz=100")
.exchange()
.expectStatus()
.isOk();

verify(service, times(1)).getCourts(null, 100);
}

@Test
void testGetCourtsWithQuery() {
when(service.getCourts(anyString(), anyInt())).thenReturn(new ArrayList<>());

risWebTestClient
.withDefaultLogin()
.get()
.uri("/api/v1/caselaw/courts?q=test")
.exchange()
.expectStatus()
.isOk();

verify(service, times(1)).getCourts("test", 200);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ void testGetTwoDifferentCourts() {
Court courtB = Court.builder().type("XYZ").location("Hamburg").build();

List<Court> returnedCourts = List.of(courtA, courtB);
when(courtRepository.findAllByOrderByTypeAscLocationAsc()).thenReturn(returnedCourts);
when(courtRepository.findAllByOrderByTypeAscLocationAsc(100)).thenReturn(returnedCourts);

List<Court> resultCourts = service.getCourts(null);
List<Court> resultCourts = service.getCourts(null, 100);

Assertions.assertEquals(returnedCourts, resultCourts);

verify(courtRepository).findAllByOrderByTypeAscLocationAsc();
verify(courtRepository).findAllByOrderByTypeAscLocationAsc(100);
}

@Test
Expand All @@ -51,13 +51,13 @@ void testGetCourtsWithSearchString() {
String trimmedSearchString = searchString.trim();

List<Court> returnedCourts = List.of(courtA, courtB);
when(courtRepository.findBySearchStr(trimmedSearchString)).thenReturn(returnedCourts);
when(courtRepository.findBySearchStr(trimmedSearchString, 100)).thenReturn(returnedCourts);

List<Court> resultCourts = service.getCourts(searchString);
List<Court> resultCourts = service.getCourts(searchString, 100);

Assertions.assertEquals(returnedCourts, resultCourts);

verify(courtRepository).findBySearchStr(trimmedSearchString);
verify(courtRepository).findBySearchStr(trimmedSearchString, 100);
}

@Test
Expand All @@ -66,12 +66,12 @@ void testGetCourtsWithBlankSearchString() {
Court courtB = Court.builder().type("XYZ").location("Hamburg").build();

List<Court> returnedCourts = List.of(courtA, courtB);
when(courtRepository.findAllByOrderByTypeAscLocationAsc()).thenReturn(returnedCourts);
when(courtRepository.findAllByOrderByTypeAscLocationAsc(100)).thenReturn(returnedCourts);

List<Court> resultCourts = service.getCourts("");
List<Court> resultCourts = service.getCourts("", 100);

Assertions.assertEquals(returnedCourts, resultCourts);

verify(courtRepository).findAllByOrderByTypeAscLocationAsc();
verify(courtRepository).findAllByOrderByTypeAscLocationAsc(100);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void testParametrizedDocumentationUnitCreation() {
when(documentNumberPatternConfig.getDocumentNumberPatterns())
.thenReturn(Map.of("DS", "XXRE0******YY"));

var court = databaseCourtRepository.findBySearchStr("AG Aachen").get(0);
var court = databaseCourtRepository.findBySearchStr("AG Aachen", 100).getFirst();

risWebTestClient
.withDefaultLogin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void setUp() {
}));

legalPeriodical =
legalPeriodicalRepository.findAllBySearchStr(Optional.of("ABC")).stream()
legalPeriodicalRepository.findAllBySearchStr("ABC").stream()
.findAny()
.orElseThrow(
() ->
Expand All @@ -174,12 +174,11 @@ void tearDown() {
@Test
void testFindLegalPeriodical_byAbbreviationOrTitle_shouldSucceed() {
Assertions.assertNotNull(
legalPeriodicalRepository.findAllBySearchStr(Optional.of("A&G")).stream().findFirst(),
legalPeriodicalRepository.findAllBySearchStr("A&G").stream().findFirst(),
"Expected a legal periodical by abbreviation but none was found");

Assertions.assertNotNull(
legalPeriodicalRepository.findAllBySearchStr(Optional.of("Arbeit & Gesundheit")).stream()
.findFirst(),
legalPeriodicalRepository.findAllBySearchStr("Arbeit & Gesundheit").stream().findFirst(),
"Expected a legal periodical by title but none was found");
}

Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/ExtraContentSidePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const props = defineProps<{
showEditButton?: boolean
hidePanelModeBar?: boolean
sidePanelMode?: SelectablePanelContent
sidePanelShortcut?: string
icon?: Component
}>()
Expand All @@ -49,6 +50,8 @@ const hasAttachments = computed(() => {
)
})
const shortCut = computed(() => props.sidePanelShortcut ?? "<")
/**
* Updates the local attachment index reference, which is used to display the selected attachment in the panel,
* if the panel content is set to "attachments".
Expand Down Expand Up @@ -149,12 +152,12 @@ onMounted(async () => {
:is-expanded="store.isExpanded"
label="Seitenpanel"
:opening-direction="OpeningDirection.LEFT"
shortcut="<"
:shortcut="shortCut"
tabindex="0"
@update:is-expanded="togglePanel"
>
<div class="m-24 flex flex-row justify-between">
<div v-if="!hidePanelModeBar" class="flex flex-row">
<div v-if="!hidePanelModeBar" class="flex flex-row -space-x-2">
<Tooltip shortcut="n" text="Notiz">
<TextButton
id="note"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/SideToggle.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { Component, computed } from "vue"
import { type Component, computed } from "vue"
import Tooltip from "./Tooltip.vue"
import IconChevronLeft from "~icons/ic/baseline-chevron-left"
import IconChevronRight from "~icons/ic/baseline-chevron-right"
Expand Down Expand Up @@ -65,7 +65,7 @@ export enum OpeningDirection {
class="w-icon relative flex min-h-32 min-w-32 items-center justify-center rounded-full border-1 border-solid border-gray-400 bg-white text-gray-900"
@click="toggle"
>
<icon v-if="icon" class="text-blue-800" />
<component :is="icon" v-if="icon" class="text-blue-800" />
<IconChevronLeft
v-else-if="
props.openingDirection === OpeningDirection.LEFT
Expand Down
Loading

0 comments on commit c9a12d1

Please sign in to comment.