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 TimingExtension implements AfterAllCallback, TestInstancePostProcessor { | |
private static final Logger logger = Logger.getLogger(TimingExtension.class.getName()); | |
private static final String START_TIME = "start time"; | |
@Override | |
public void postProcessTestInstance(Object testInstance, ExtensionContext context) { | |
getStore(context).put(START_TIME, System.currentTimeMillis()); | |
} |
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
package no.vegvesen.kjoretoy.registrering.register.web; | |
import javax.persistence.EntityManager; | |
import javax.persistence.PersistenceContext; | |
import javax.persistence.Table; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
import org.springframework.beans.factory.InitializingBean; |
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
<profile> | |
<id>appConfigTest</id> | |
<build> | |
<plugins> | |
<plugin> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<configuration combine.self="override"> | |
<groups>appConfigTest</groups> | |
</configuration> | |
</plugin> |
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
Testfile located in src/test/resources/testdata/my-test-data.xml. | |
src/test/resources is current directory when running the test, so not needed in path. | |
new String(Files.readAllBytes(Paths.get(this.getClass().getResource("/testdata/my-test-data.xml").getPath()))) |
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.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import org.junit.jupiter.api.DisplayName; | |
import org.junit.jupiter.api.Nested; | |
import org.junit.jupiter.api.Tag; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.extension.ExtendWith; |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example</groupId> | |
<artifactId>yaml-merge-keys</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>jar</packaging> |
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 org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
class GenericErrorHandlingWithSupplier { | |
private static final Logger LOGGER = LoggerFactory.getLogger(GenericErrorHandlingWithSupplier.class); | |
public static void main(String[] args) { | |
// Example 1: Every caller needs to catch all relevant exceptions |
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
https://httpie.org/ | |
File that needs to be available and executable on path: | |
#!/bin/bash | |
USERID="user-id:AKRF1110" | |
XAUTHTOKEN="X-Auth-Token:$(cat /tmp/jwttoken.txt)" | |
http --timeout=9999999 "$@" $USERID $XAUTHTOKEN | |
Test: |
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
@SpringBootApplication | |
public class WrappedresourcesspringhateoasApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(WrappedresourcesspringhateoasApplication.class, args); | |
} | |
} | |
@RestController | |
class FooController { |
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 Java8ComparatorTest { | |
@Test | |
public void testJava8ChainedComparators() { | |
Comparator<Person> personComparator = Comparator.comparingInt(Person::getAge) | |
.thenComparing(Person::getName) | |
.thenComparing(Person::getOccupation, (o1, o2) -> { | |
return o1.compareTo(o2); | |
}); |