diff --git a/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8GroupingByCollectorUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java_8_features/groupingby/Java8GroupingByCollectorUnitTest.java similarity index 99% rename from core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8GroupingByCollectorUnitTest.java rename to core-java-modules/core-java-8/src/test/java/com/baeldung/java_8_features/groupingby/Java8GroupingByCollectorUnitTest.java index eea019da2c..323586b85f 100644 --- a/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/Java8GroupingByCollectorUnitTest.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/java_8_features/groupingby/Java8GroupingByCollectorUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java8; +package com.baeldung.java_8_features.groupingby; import com.baeldung.java_8_features.groupingby.BlogPost; import com.baeldung.java_8_features.groupingby.BlogPostType; diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/JacksonSerializationIgnoreUnitTest.java similarity index 98% rename from jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/ignore/JacksonSerializationIgnoreUnitTest.java index 146f274380..da8b464d03 100644 --- a/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java +++ b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/JacksonSerializationIgnoreUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jackson.test; +package com.baeldung.jackson.ignore; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -15,9 +15,9 @@ import com.baeldung.jackson.dtos.MyDtoIncludeNonDefault; import com.baeldung.jackson.dtos.MyDtoWithFilter; import com.baeldung.jackson.dtos.MyDtoWithSpecialField; import com.baeldung.jackson.dtos.MyMixInForIgnoreType; -import com.baeldung.jackson.dtos.ignore.MyDtoIgnoreField; -import com.baeldung.jackson.dtos.ignore.MyDtoIgnoreFieldByName; -import com.baeldung.jackson.dtos.ignore.MyDtoIgnoreNull; +import com.baeldung.jackson.ignore.dtos.MyDtoIgnoreField; +import com.baeldung.jackson.ignore.dtos.MyDtoIgnoreFieldByName; +import com.baeldung.jackson.ignore.dtos.MyDtoIgnoreNull; import com.baeldung.jackson.serialization.MyDtoNullKeySerializer; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonGenerator; diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreField.java similarity index 94% rename from jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java rename to jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreField.java index f573501e85..8cbcb773cc 100644 --- a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java +++ b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreField.java @@ -1,4 +1,4 @@ -package com.baeldung.jackson.dtos.ignore; +package com.baeldung.jackson.ignore.dtos; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreFieldByName.java similarity index 95% rename from jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java rename to jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreFieldByName.java index e7b8ea2a8e..1aee31a1b3 100644 --- a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java +++ b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreFieldByName.java @@ -1,4 +1,4 @@ -package com.baeldung.jackson.dtos.ignore; +package com.baeldung.jackson.ignore.dtos; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreNull.java similarity index 96% rename from jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java rename to jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreNull.java index bc443500a1..75532f18c2 100644 --- a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java +++ b/jackson-simple/src/test/java/com/baeldung/jackson/ignore/dtos/MyDtoIgnoreNull.java @@ -1,4 +1,4 @@ -package com.baeldung.jackson.dtos.ignore; +package com.baeldung.jackson.ignore.dtos; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/java-streams/src/test/java/com/baeldung/java8/Java8FindAnyFindFirstUnitTest.java b/java-streams/src/test/java/com/baeldung/java8/streams/Java8FindAnyFindFirstUnitTest.java similarity index 97% rename from java-streams/src/test/java/com/baeldung/java8/Java8FindAnyFindFirstUnitTest.java rename to java-streams/src/test/java/com/baeldung/java8/streams/Java8FindAnyFindFirstUnitTest.java index 8c2e0628fa..5f52fe375e 100644 --- a/java-streams/src/test/java/com/baeldung/java8/Java8FindAnyFindFirstUnitTest.java +++ b/java-streams/src/test/java/com/baeldung/java8/streams/Java8FindAnyFindFirstUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java8; +package com.baeldung.java8.streams; import org.junit.Test; diff --git a/java-streams/src/test/java/com/baeldung/java8/Java8StreamApiUnitTest.java b/java-streams/src/test/java/com/baeldung/java8/streams/Java8StreamApiUnitTest.java similarity index 99% rename from java-streams/src/test/java/com/baeldung/java8/Java8StreamApiUnitTest.java rename to java-streams/src/test/java/com/baeldung/java8/streams/Java8StreamApiUnitTest.java index 5005cf7f47..75cfbc049f 100644 --- a/java-streams/src/test/java/com/baeldung/java8/Java8StreamApiUnitTest.java +++ b/java-streams/src/test/java/com/baeldung/java8/streams/Java8StreamApiUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java8; +package com.baeldung.java8.streams; import com.baeldung.stream.Product; import org.junit.Before; diff --git a/libraries-primitive/pom.xml b/libraries-primitive/pom.xml index 12fc35c1b5..cddb3ab1fe 100644 --- a/libraries-primitive/pom.xml +++ b/libraries-primitive/pom.xml @@ -9,9 +9,14 @@ 1.0-SNAPSHOT libraries-primitive + + 1.8 + 1.8 + + - - + + it.unimi.dsi fastutil 8.2.2 @@ -36,5 +41,18 @@ 1.19 test + + + org.eclipse.collections + eclipse-collections-api + 10.0.0 + + + + org.eclipse.collections + eclipse-collections + 10.0.0 + + - + \ No newline at end of file diff --git a/libraries-primitive/src/test/java/com/baeldung/PrimitiveCollectionsUnitTest.java b/libraries-primitive/src/test/java/com/baeldung/PrimitiveCollectionsUnitTest.java new file mode 100644 index 0000000000..2adecd37fc --- /dev/null +++ b/libraries-primitive/src/test/java/com/baeldung/PrimitiveCollectionsUnitTest.java @@ -0,0 +1,70 @@ +package com.baeldung; + +import org.eclipse.collections.api.list.primitive.ImmutableIntList; +import org.eclipse.collections.api.list.primitive.MutableLongList; +import org.eclipse.collections.api.map.primitive.MutableIntIntMap; +import org.eclipse.collections.api.set.primitive.MutableIntSet; +import org.eclipse.collections.impl.factory.primitive.*; +import org.eclipse.collections.impl.list.Interval; +import org.eclipse.collections.impl.list.primitive.IntInterval; +import org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap; +import org.junit.Test; + +import java.util.stream.DoubleStream; + +import static org.junit.Assert.assertEquals; + + +public class PrimitiveCollectionsUnitTest { + + @Test + public void whenListOfLongHasOneTwoThree_thenSumIsSix() { + MutableLongList longList = LongLists.mutable.of(1L, 2L, 3L); + assertEquals(6, longList.sum()); + } + + @Test + public void whenListOfIntHasOneTwoThree_thenMaxIsThree() { + ImmutableIntList intList = IntLists.immutable.of(1, 2, 3); + assertEquals(3, intList.max()); + } + + @Test + public void whenConvertFromIterableToPrimitive_thenValuesAreEquals() { + Iterable iterable = Interval.oneTo(3); + MutableIntSet intSet = IntSets.mutable.withAll(iterable); + IntInterval intInterval = IntInterval.oneTo(3); + assertEquals(intInterval.toSet(), intSet); + } + + @Test + public void testOperationsOnIntIntMap() { + MutableIntIntMap map = new IntIntHashMap(); + assertEquals(5, map.addToValue(0, 5)); + assertEquals(5, map.get(0)); + assertEquals(3, map.getIfAbsentPut(1, 3)); + } + + @Test + public void whenCreateDoubleStream_thenAverageIsThree() { + DoubleStream doubleStream = DoubleLists + .mutable.with(1.0, 2.0, 3.0, 4.0, 5.0) + .primitiveStream(); + assertEquals(3, doubleStream.average().getAsDouble(), 0.001); + } + + @Test + public void whenCreateMapFromStream_thenValuesMustMatch() { + Iterable integers = Interval.oneTo(3); + MutableIntIntMap map = + IntIntMaps.mutable.from( + integers, + key -> key, + value -> value * value); + MutableIntIntMap expected = IntIntMaps.mutable.empty() + .withKeyValue(1, 1) + .withKeyValue(2, 4) + .withKeyValue(3, 9); + assertEquals(expected, map); + } +} \ No newline at end of file diff --git a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/SpringBootSecurityApplication.java b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/autoconfig/SpringBootSecurityApplication.java similarity index 80% rename from spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/SpringBootSecurityApplication.java rename to spring-boot-security/src/main/java/com/baeldung/springbootsecurity/autoconfig/SpringBootSecurityApplication.java index 7007c15596..3afeda66a4 100644 --- a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/SpringBootSecurityApplication.java +++ b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/autoconfig/SpringBootSecurityApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.springbootsecurity.basic_auth; +package com.baeldung.springbootsecurity.autoconfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,7 +7,7 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfi @SpringBootApplication(exclude = { SecurityAutoConfiguration.class // ,ManagementWebSecurityAutoConfiguration.class -}, scanBasePackages = "com.baeldung.springbootsecurity.basic_auth") +}, scanBasePackages = "com.baeldung.springbootsecurity.autoconfig") public class SpringBootSecurityApplication { public static void main(String[] args) { SpringApplication.run(SpringBootSecurityApplication.class, args); diff --git a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicConfiguration.java b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/autoconfig/config/BasicConfiguration.java similarity index 95% rename from spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicConfiguration.java rename to spring-boot-security/src/main/java/com/baeldung/springbootsecurity/autoconfig/config/BasicConfiguration.java index 3cfa45421c..7060792df5 100644 --- a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicConfiguration.java +++ b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/autoconfig/config/BasicConfiguration.java @@ -1,4 +1,4 @@ -package com.baeldung.springbootsecurity.basic_auth.config; +package com.baeldung.springbootsecurity.autoconfig.config; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; diff --git a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicConfigurationIntegrationTest.java b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/autoconfig/config/BasicConfigurationIntegrationTest.java similarity index 93% rename from spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicConfigurationIntegrationTest.java rename to spring-boot-security/src/test/java/com/baeldung/springbootsecurity/autoconfig/config/BasicConfigurationIntegrationTest.java index f221712513..a28d0f5e26 100644 --- a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicConfigurationIntegrationTest.java +++ b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/autoconfig/config/BasicConfigurationIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.springbootsecurity.basic_auth; +package com.baeldung.springbootsecurity.autoconfig.config; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -18,6 +18,8 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.springbootsecurity.autoconfig.SpringBootSecurityApplication; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = RANDOM_PORT, classes = SpringBootSecurityApplication.class) public class BasicConfigurationIntegrationTest {