This file contains 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.time.LocalDate; | |
public class Game { | |
static HighscoreEntry[] highscore = new HighscoreEntry[10]; | |
public static void main(String[] args) { | |
addHighscore("Bob", 500); | |
addHighscore("Kevin", 440); | |
addHighscore("Dave", 600); |
This file contains 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.Arrays; | |
public class MergeDemo { | |
public static void main(String[] args) { | |
// Testfälle und Ausgaben. Von trivial über einfach bis schwer | |
System.out.println(Arrays.toString(m(new double[]{}, new double[]{})) + " erwartet: leer"); | |
System.out.println(Arrays.toString(m(new double[]{0}, new double[]{0})) + " erwartet: 0 0"); | |
System.out.println(Arrays.toString(m(new double[]{0}, new double[]{1})) + " erwartet: 1 0"); |
This file contains 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
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | |
@ActiveProfiles("test") | |
@RunWith(SpringJUnit4ClassRunner::class) | |
class ProductE2ESpringBootTest { | |
@Autowired | |
lateinit var client: TestRestTemplate | |
@Autowired | |
lateinit var repository: ProductRepository |
This file contains 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
class ProductE2EContainerlessTest { | |
private lateinit var flyway: Flyway | |
private lateinit var entityManager: EntityManager | |
private lateinit var repository: ProductRepository | |
private val authService = mock(AuthService::class.java) | |
private val auditLoggerClient = mock(AuditLoggerClient::class.java) | |
private lateinit var client: MockMvc |
This file contains 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
@Test | |
fun `findMostOrderedProducts - 6 orders for 3 products in db - returns Top 2`() { | |
// given | |
val numberOfProducts = 2 | |
val product1 = Product("1", "Ryzen 7 2700X", "AMD") | |
val product2 = Product("2", "Core i9 9900K", "Intel") | |
val product3 = Product("3", "Ryzen Threadripper 2990WX", "AMD") | |
productRepository.saveAll(setOf(product1, product2, product3)) | |
persistNewOrderForProduct(product1.id) |
This file contains 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
@Test | |
fun `findMostOrderedProducts - 6 orders for 3 products in db - returns Top 2`() { | |
// given | |
val numberOfProducts = 2 | |
val product1 = Product("1", "Ryzen 7 2700X", "AMD") | |
val product2 = Product("2", "Core i9 9900K", "Intel") | |
val product3 = Product("3", "Ryzen Threadripper 2990WX", "AMD") | |
productRepository.saveAll(setOf(product1, product2, product3)) | |
val order1 = Order("1", 1, product1.id, LocalDate.now(), 1) |
This file contains 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
@Test | |
fun `findMostOrderedProducts - 6 orders for 3 products in db - returns Top 2`() { | |
// given | |
val numberOfProducts = 2 | |
val product1 = Product("1", "Ryzen 7 2700X", "AMD") | |
val product2 = Product("2", "Core i9 9900K", "Intel") | |
// when | |
val foundProducts = productRepository.findMostOrderedProducts(numberOfProducts) |
This file contains 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
@Test | |
fun `findMostOrderedProducts - 6 orders for 3 products in db - returns Top 2`() { | |
// given | |
// when | |
val foundProducts = productRepository.findMostOrderedProducts(numberOfProducts) | |
// then | |
assertThat(foundProducts).hasSize(numberOfProducts) | |
assertThat(foundProducts).containsExactlyInAnyOrder(product1, product2) |
This file contains 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
@Test | |
fun `findMostOrderedProducts - 6 orders for 3 products in db - returns Top 2`() { | |
// given | |
// when | |
val foundProducts = productRepository.findMostOrderedProducts(2) | |
// then | |
} |
This file contains 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
@Test | |
fun `findMostOrderedProducts - no orders in db - return empty list`() { | |
// given | |
productRepository.save(Product("1", "Ryzen 7 2700X", "AMD")) | |
productRepository.save(Product("2", "Core i9 9900K", "Intel")) | |
// when | |
val foundProducts = productRepository.findMostOrderedProducts(1) | |
// then |
NewerOlder