Skip to content

Commit

Permalink
NfcTest enabled und implementiert, CacheControlTest removed TestConst…
Browse files Browse the repository at this point in the history
…ants bereinigt
  • Loading branch information
Nic12345678 committed Sep 30, 2024
1 parent e9bc500 commit 0f460a3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
package de.muenchen.oss.wahllokalsystem.briefwahlservice;

import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.springframework.hateoas.RepresentationModel;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class TestConstants {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
import static de.muenchen.oss.wahllokalsystem.briefwahlservice.TestConstants.SPRING_TEST_PROFILE;

import de.muenchen.oss.wahllokalsystem.briefwahlservice.MicroServiceApplication;
import org.junit.jupiter.api.Disabled;
import de.muenchen.oss.wahllokalsystem.briefwahlservice.common.beanstandetewahlbriefe.Zurueckweisungsgrund;
import de.muenchen.oss.wahllokalsystem.briefwahlservice.domain.BeanstandeteWahlbriefeRepository;
import de.muenchen.oss.wahllokalsystem.briefwahlservice.rest.beanstandetewahlbriefe.BeanstandeteWahlbriefeDTO;
import java.net.URI;
import java.util.Map;
import lombok.val;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.data.util.Streamable;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest(
Expand All @@ -26,7 +33,7 @@
@ActiveProfiles(profiles = { SPRING_TEST_PROFILE, SPRING_NO_SECURITY_PROFILE })
class UnicodeConfigurationTest {

private static final String ENTITY_ENDPOINT_URL = "/theEntities";
private static final String BEANSTANDETE_WAHLBRIEFE_ENDPOINT_URL = "/businessActions/beanstandeteWahlbriefe/";

/**
* Decomposed string: String "Ä-é" represented with unicode letters "A◌̈-e◌́"
Expand All @@ -41,12 +48,33 @@ class UnicodeConfigurationTest {
@Autowired
private TestRestTemplate testRestTemplate;

@Autowired
private BeanstandeteWahlbriefeRepository beanstandeteWahlbriefeRepository;

@Test
@Disabled
void testForNfcNormalization() {
// Persist entity with decomposed string.
val wahlbezirkID = "wahlbezirkID";
val waehlerVerzeichnisNummer = 1L;
val key1 = "key1";
val key2 = "key2";
val beanstandeteWahlbriefeDTO = createControllerBeanstandeteWahlbriefeDTO(wahlbezirkID, waehlerVerzeichnisNummer, key1, key2, TEXT_ATTRIBUTE_DECOMPOSED);
Assertions.assertThat((String)beanstandeteWahlbriefeDTO.beanstandeteWahlbriefe().keySet().toArray()[0]).hasSize(key1.length() + TEXT_ATTRIBUTE_DECOMPOSED.length());
Assertions.assertThat((String)beanstandeteWahlbriefeDTO.beanstandeteWahlbriefe().keySet().toArray()[1]).hasSize(key2.length() + TEXT_ATTRIBUTE_DECOMPOSED.length());

testRestTemplate.postForEntity(URI.create(BEANSTANDETE_WAHLBRIEFE_ENDPOINT_URL + wahlbezirkID + "/" + waehlerVerzeichnisNummer), beanstandeteWahlbriefeDTO, Void.class);

val beantstandeteWahlbriefeInRepo = Streamable.of(beanstandeteWahlbriefeRepository.findAll()).toList();
Assertions.assertThat(beantstandeteWahlbriefeInRepo).hasSize(1);
Assertions.assertThat(beantstandeteWahlbriefeInRepo.get(0).getBeanstandeteWahlbriefe().keySet().toArray()[0]).isEqualTo(key1 + TEXT_ATTRIBUTE_COMPOSED);
Assertions.assertThat(beantstandeteWahlbriefeInRepo.get(0).getBeanstandeteWahlbriefe().keySet().toArray()[1]).isEqualTo(key2 + TEXT_ATTRIBUTE_COMPOSED);
}

private BeanstandeteWahlbriefeDTO createControllerBeanstandeteWahlbriefeDTO(String wahlbezirkID, Long waehlerverzeichnisNummer, String key1, String key2, String textAttributeDecomposed) {
return new BeanstandeteWahlbriefeDTO(wahlbezirkID, waehlerverzeichnisNummer,
Map.of(key1 + textAttributeDecomposed, new Zurueckweisungsgrund[]{Zurueckweisungsgrund.NICHT_WAHLBERECHTIGT, Zurueckweisungsgrund.GEGENSTAND_IM_UMSCHLAG},
key2 + textAttributeDecomposed, new Zurueckweisungsgrund[]{Zurueckweisungsgrund.UNTERSCHRIFT_FEHLT, Zurueckweisungsgrund.LOSE_STIMMZETTEL})
);
}

}

0 comments on commit 0f460a3

Please sign in to comment.