Java Map with Insertion Order

In Java, we can use LinkedHashMap to keep the insertion order. P.S HashMap does not guarantee insertion order. 1. HashMap Generate a HashMap, UUID as key, index 0, 1, 2, 3, 4… as value. JavaHashMap.java package com.mkyong.samples; import java.util.HashMap; import java.util.Map; import java.util.UUID; import java.util.stream.IntStream; public class JavaHashMap { public static void main(String[] args) { …

Read more

JUnit 5 Test Execution Order

This article shows you how to control the JUnit 5 test execution order via the following MethodOrderer classes: Alphanumeric OrderAnnotation Random Custom Order P.S Tested with JUnit 5.5.2 1. Alphanumeric 1.1 It sorts test methods alphanumerically. MethodAlphanumericTest.java package com.mkyong.order; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; import static org.junit.jupiter.api.Assertions.assertEquals; @TestMethodOrder(MethodOrderer.Alphanumeric.class) public class MethodAlphanumericTest { @Test void …

Read more