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
import java.util.regex.Pattern; | |
import static org.assertj.core.api.Assertions.assertThat; | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import io.swagger.v3.oas.models.OpenAPI; | |
import org.junit.jupiter.api.Test; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; |
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
import java.util.Map; | |
import jakarta.servlet.RequestDispatcher; | |
import jakarta.servlet.http.HttpServletRequest; | |
import org.springframework.boot.web.servlet.error.ErrorController; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.MediaType; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.RequestMapping; |
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
public class FileResponseResource extends ByteArrayResource { | |
private final String fileName; | |
private final int fileLength; | |
public FileResponseResource(String fileName, final byte[] byteArray) { | |
super(byteArray); | |
this.fileName = Objects.requireNonNull(fileName); | |
this.fileLength = byteArray.length; | |
} |
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
public class CountryCodeValidator implements ConstraintValidator<ValidIso2CountryCode, String> { | |
private static final Set<String> isoCountries = Locale.getISOCountries(Locale.IsoCountryCode.PART1_ALPHA2); | |
@Override | |
public boolean isValid(String content, ConstraintValidatorContext context) { | |
if (content == null) { | |
setErrorMessage(context, "Country code must not be null"); | |
return false; | |
} |