Skip to content
Snippets Groups Projects
Commit f537d70a authored by Samuel Eickelberg's avatar Samuel Eickelberg
Browse files

Code formatted after merge #2

parent c2b170cc
No related branches found
No related tags found
No related merge requests found
Pipeline #58613 failed
...@@ -79,6 +79,22 @@ public class CalibrationCertificateController { ...@@ -79,6 +79,22 @@ public class CalibrationCertificateController {
this.service = service; this.service = service;
} }
private static String getDetailedXmlError(String xml, Exception e) {
StringBuilder details = new StringBuilder(createLogEntry(e));
if (e instanceof JAXBException && (((JAXBException) e).getLinkedException() instanceof SAXParseException)) {
int line = ((SAXParseException) ((JAXBException) e).getLinkedException()).getLineNumber();
details.append(" Invalid xml: (line ").append(line).append(") :").append(System.lineSeparator());
Object[] xmlLines = xml.lines().toArray();
for (int i = Math.max(0, line - 3); i <= Math.min(xmlLines.length - 1, line + 3); i++) {
details.append(i).append(": ").append(xmlLines[i].toString()).append(System.lineSeparator());
}
}
String detailsMessage = details.toString();
log.error("Problem detected with provided XML: " + detailsMessage);
log.error("Problematic XML: " + xml);
return detailsMessage;
}
@Operation(description = "Convert a DCC DTO as JSON to XML") @Operation(description = "Convert a DCC DTO as JSON to XML")
@PostMapping(path = DCC_XML_PATH, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_XML_VALUE) @PostMapping(path = DCC_XML_PATH, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_XML_VALUE)
public String convertAndValidate(@RequestBody CalibrationCertificateDto dcc) { public String convertAndValidate(@RequestBody CalibrationCertificateDto dcc) {
...@@ -130,20 +146,4 @@ public class CalibrationCertificateController { ...@@ -130,20 +146,4 @@ public class CalibrationCertificateController {
throw new BadRequestStatus(createLogEntry(e)); throw new BadRequestStatus(createLogEntry(e));
} }
} }
private static String getDetailedXmlError(String xml, Exception e) {
StringBuilder details = new StringBuilder(createLogEntry(e));
if (e instanceof JAXBException && (((JAXBException) e).getLinkedException() instanceof SAXParseException)) {
int line = ((SAXParseException) ((JAXBException) e).getLinkedException()).getLineNumber();
details.append(" Invalid xml: (line ").append(line).append(") :").append(System.lineSeparator());
Object[] xmlLines = xml.lines().toArray();
for (int i = Math.max(0, line - 3); i <= Math.min(xmlLines.length - 1, line + 3); i++) {
details.append(i).append(": ").append(xmlLines[i].toString()).append(System.lineSeparator());
}
}
String detailsMessage = details.toString();
log.error("Problem detected with provided XML: " + detailsMessage);
log.error("Problematic XML: " + xml);
return detailsMessage;
}
} }
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE. OF THE POSSIBILITY OF SUCH DAMAGE.
--> -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" <schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.w3.org/2000/09/xmldsig#"
version="0.1" elementFormDefault="qualified"> version="0.1" elementFormDefault="qualified">
<simpleType name="CryptoBinary"> <simpleType name="CryptoBinary">
......
...@@ -34,7 +34,6 @@ import org.junit.jupiter.api.AfterEach; ...@@ -34,7 +34,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import java.util.Date; import java.util.Date;
...@@ -45,16 +44,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; ...@@ -45,16 +44,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DataJpaTest @DataJpaTest
class CalibrationCertificateRepositoryTest { class CalibrationCertificateRepositoryTest {
private final long currentTimeMillis = System.currentTimeMillis();
@Autowired @Autowired
private CalibrationCertificateRepository repository; private CalibrationCertificateRepository repository;
@Autowired @Autowired
private CalibrationCertificateConfiguration configuration; private CalibrationCertificateConfiguration configuration;
private String expiredId; private String expiredId;
private final long currentTimeMillis = System.currentTimeMillis();
@BeforeEach @BeforeEach
void setUp() { void setUp() {
long expiredTimeMillis = currentTimeMillis - configuration.getPersistLifespan().longValue() * 1001L; long expiredTimeMillis = currentTimeMillis - configuration.getPersistLifespan().longValue() * 1001L;
......
...@@ -66,24 +66,19 @@ import static org.mockito.Mockito.when; ...@@ -66,24 +66,19 @@ import static org.mockito.Mockito.when;
@SpringBootTest @SpringBootTest
class CacheServiceTest { class CacheServiceTest {
private final Long cacheItemId = RandomUtils.nextLong();
private final Date createdAt = new Date(System.currentTimeMillis());
@MockBean @MockBean
private VersionConfiguration versionConfiguration; private VersionConfiguration versionConfiguration;
@MockBean @MockBean
private CacheConfiguration configuration; private CacheConfiguration configuration;
@MockBean @MockBean
private CacheItemRepository repository; private CacheItemRepository repository;
@Captor @Captor
private ArgumentCaptor<Date> dateCaptor; private ArgumentCaptor<Date> dateCaptor;
private CacheService service; private CacheService service;
private CacheItem cacheItem; private CacheItem cacheItem;
private final Long cacheItemId = RandomUtils.nextLong();
private final Date createdAt = new Date(System.currentTimeMillis());
@BeforeEach @BeforeEach
void setUp() { void setUp() {
when(versionConfiguration.getArtifactId()).thenReturn("cache-service-test"); when(versionConfiguration.getArtifactId()).thenReturn("cache-service-test");
......
{"any":"<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n \n<head>\n<title>MathML's Hello Square</title>\n</head>\n\n<body>\n\n<p> This is a perfect square:</p>\n\n<math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n <mrow>\n <msup>\n <mfenced>\n <mrow>\n <mi>a</mi>\n <mo>+</mo>\n <mi>b</mi>\n </mrow>\n </mfenced>\n <mn>2</mn>\n </msup>\n </mrow> \n</math>\n\n</body>\n</html>"} {
\ No newline at end of file "any" : "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n \n<head>\n<title>MathML's Hello Square</title>\n</head>\n\n<body>\n\n<p> This is a perfect square:</p>\n\n<math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n <mrow>\n <msup>\n <mfenced>\n <mrow>\n <mi>a</mi>\n <mo>+</mo>\n <mi>b</mi>\n </mrow>\n </mfenced>\n <mn>2</mn>\n </msup>\n </mrow> \n</math>\n\n</body>\n</html>"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment