-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
324 additions
and
7 deletions.
There are no files selected for viewing
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
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
20 changes: 20 additions & 0 deletions
20
...Standard-Core-Library/src/test/java/com/yelstream/topp/standard/lang/ComparablesTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.yelstream.topp.standard.lang; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test of {@link Comparables}. | ||
* | ||
* @author Morten Sabroe Mortensen | ||
* @version 1.0 | ||
* @since 2024-04-24 | ||
*/ | ||
@Slf4j | ||
class ComparablesTest { | ||
|
||
@Test | ||
void xxx() { | ||
|
||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Topp-Standard-Core-Library/src/test/java/com/yelstream/topp/standard/lang/LangTestSuite.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.yelstream.topp.standard.lang; | ||
|
||
import org.junit.platform.suite.api.SelectClasses; | ||
import org.junit.platform.suite.api.Suite; | ||
|
||
/** | ||
* Test suite for {@code com.yelstream.topp.standard.lang}. | ||
* | ||
* @author Morten Sabroe Mortensen | ||
* @version 1.0 | ||
* @since 2024-04-24 | ||
*/ | ||
@Suite | ||
@SelectClasses({ComparablesTest.class,RunnablesTest.class,ServiceLoadersTest.class,StringsTest.class}) | ||
class LangTestSuite { | ||
} |
20 changes: 20 additions & 0 deletions
20
Topp-Standard-Core-Library/src/test/java/com/yelstream/topp/standard/lang/RunnablesTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.yelstream.topp.standard.lang; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test of {@link Runnables}. | ||
* | ||
* @author Morten Sabroe Mortensen | ||
* @version 1.0 | ||
* @since 2024-04-24 | ||
*/ | ||
@Slf4j | ||
class RunnablesTest { | ||
|
||
@Test | ||
void xxx() { | ||
|
||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ndard-Core-Library/src/test/java/com/yelstream/topp/standard/lang/ServiceLoadersTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.yelstream.topp.standard.lang; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test of {@link ServiceLoaders}. | ||
* | ||
* @author Morten Sabroe Mortensen | ||
* @version 1.0 | ||
* @since 2024-04-24 | ||
*/ | ||
@Slf4j | ||
class ServiceLoadersTest { | ||
|
||
@Test | ||
void xxx() { | ||
|
||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
Topp-Standard-Core-Library/src/test/java/com/yelstream/topp/standard/lang/StringsTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package com.yelstream.topp.standard.lang; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Test of {@link Strings}. | ||
* | ||
* @author Morten Sabroe Mortensen | ||
* @version 1.0 | ||
* @since 2024-04-24 | ||
*/ | ||
@Slf4j | ||
class StringsTest { | ||
/** | ||
* Test of {@link Strings#trim(String)}. | ||
*/ | ||
@SuppressWarnings("ConstantValue") | ||
@Test | ||
void trim() { | ||
Assertions.assertNull(Strings.trim(null)); | ||
Assertions.assertEquals("abc",Strings.trim("abc")); | ||
Assertions.assertEquals("abc",Strings.trim(" abc ")); | ||
} | ||
|
||
/** | ||
* Test of {@link Strings#isEmpty(String)}. | ||
*/ | ||
@SuppressWarnings("ConstantValue") | ||
@Test | ||
void isEmpty() { | ||
Assertions.assertTrue(Strings.isEmpty(null)); | ||
Assertions.assertTrue(Strings.isEmpty("")); | ||
Assertions.assertFalse(Strings.isEmpty(" ")); | ||
Assertions.assertFalse(Strings.isEmpty("abc")); | ||
} | ||
|
||
/** | ||
* Test of {@link Strings#isNonEmpty(String)}. | ||
*/ | ||
@SuppressWarnings("ConstantValue") | ||
@Test | ||
void isNonEmpty() { | ||
Assertions.assertFalse(Strings.isNonEmpty(null)); | ||
Assertions.assertFalse(Strings.isNonEmpty("")); | ||
Assertions.assertTrue(Strings.isNonEmpty(" ")); | ||
Assertions.assertTrue(Strings.isNonEmpty("abc")); | ||
} | ||
|
||
/** | ||
* Test of {@link Strings#nonNullOrElse(String,String)}. | ||
*/ | ||
@SuppressWarnings({"ConstantValue","ObviousNullCheck"}) | ||
@Test | ||
void nonNullOrElseWithValue() { | ||
Assertions.assertEquals("xyz",Strings.nonNullOrElse(null,"xyz")); | ||
Assertions.assertNull(Strings.nonNullOrElse(null,(String)null)); | ||
Assertions.assertEquals("",Strings.nonNullOrElse("","xyz")); | ||
Assertions.assertEquals(" ",Strings.nonNullOrElse(" ","xyz")); | ||
Assertions.assertEquals("abc",Strings.nonNullOrElse("abc","xyz")); | ||
} | ||
|
||
/** | ||
* Test of {@link Strings#nonNullOrElse(String,Supplier)}. | ||
*/ | ||
@Test | ||
void nonNullOrElseWithSupplier() { | ||
Assertions.assertEquals("xyz",Strings.nonNullOrElse(null,()->"xyz")); | ||
Assertions.assertNull(Strings.nonNullOrElse(null,()->null)); | ||
Assertions.assertEquals("",Strings.nonNullOrElse("",()->"xyz")); | ||
Assertions.assertEquals(" ",Strings.nonNullOrElse(" ",()->"xyz")); | ||
Assertions.assertEquals("abc",Strings.nonNullOrElse("abc",()->"xyz")); | ||
} | ||
|
||
|
||
/** | ||
* Test of {@link Strings#nonEmptyOrElse(String,String)}. | ||
*/ | ||
@Test | ||
void nonEmptyOrElseWithValue() { | ||
Assertions.assertEquals("xyz",Strings.nonEmptyOrElse(null,"xyz")); | ||
Assertions.assertNull(Strings.nonEmptyOrElse(null,(String)null)); | ||
Assertions.assertEquals("xyz",Strings.nonEmptyOrElse("","xyz")); | ||
Assertions.assertEquals(" ",Strings.nonEmptyOrElse(" ","xyz")); | ||
Assertions.assertEquals("abc",Strings.nonEmptyOrElse("abc","xyz")); | ||
} | ||
|
||
/** | ||
* Test of {@link Strings#nonEmptyOrElse(String,Supplier)}. | ||
*/ | ||
@Test | ||
void nonEmptyOrElseWithSupplier() { | ||
Assertions.assertEquals("xyz",Strings.nonEmptyOrElse(null,()->"xyz")); | ||
Assertions.assertNull(Strings.nonEmptyOrElse(null,()->null)); | ||
Assertions.assertEquals("xyz",Strings.nonEmptyOrElse("",()->"xyz")); | ||
Assertions.assertEquals(" ",Strings.nonEmptyOrElse(" ",()->"xyz")); | ||
Assertions.assertEquals("abc",Strings.nonEmptyOrElse("abc",()->"xyz")); | ||
} | ||
|
||
/** | ||
* Test of {@link Strings#distinct(List)}. | ||
*/ | ||
@SuppressWarnings("ArraysAsListWithZeroOrOneArgument") | ||
@Test | ||
void distinct() { | ||
Assertions.assertNull(Strings.distinct(null)); | ||
Assertions.assertEquals(List.of(),Strings.distinct(Arrays.asList(null,null,"",null," "))); | ||
Assertions.assertEquals(Arrays.asList("abc"),Strings.distinct(Arrays.asList(null,null,"abc",null))); | ||
Assertions.assertEquals(Arrays.asList("abc","xyz"),Strings.distinct(Arrays.asList("abc"," ","xyz"))); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...re-Library/src/test/java/com/yelstream/topp/standard/util/function/FunctionTestSuite.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.yelstream.topp.standard.util.function; | ||
|
||
import org.junit.platform.suite.api.SelectClasses; | ||
import org.junit.platform.suite.api.Suite; | ||
|
||
/** | ||
* Test suite for {@code com.yelstream.topp.standard.util.function}. | ||
* | ||
* @author Morten Sabroe Mortensen | ||
* @version 1.0 | ||
* @since 2024-04-24 | ||
*/ | ||
@Suite | ||
@SelectClasses({SuppliersTest.class}) | ||
class StreamTestSuite { | ||
} |
71 changes: 71 additions & 0 deletions
71
...d-Core-Library/src/test/java/com/yelstream/topp/standard/util/function/SuppliersTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.yelstream.topp.standard.util.function; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Test of {@link Suppliers}. | ||
* | ||
* @author Morten Sabroe Mortensen | ||
* @version 1.0 | ||
* @since 2024-04-24 | ||
*/ | ||
@Slf4j | ||
class SuppliersTest { | ||
/** | ||
* Test of {@link Suppliers#fix(Object)}. | ||
*/ | ||
@Test | ||
void fixWithValue() { | ||
Supplier<Integer> supplier=Suppliers.fix(117); | ||
|
||
Assertions.assertEquals(117,supplier.get()); //First invocation | ||
Assertions.assertEquals(117,supplier.get()); //Second invocation | ||
Assertions.assertEquals(117,supplier.get()); //Third invocation | ||
} | ||
|
||
/** | ||
* Test of {@link Suppliers#fix(Supplier)}. | ||
*/ | ||
@Test | ||
void fix() { | ||
Supplier<Integer> source=()->117; | ||
Supplier<Integer> supplier=Suppliers.fix(source); | ||
|
||
Assertions.assertEquals(117,supplier.get()); //First invocation | ||
Assertions.assertEquals(117,supplier.get()); //Second invocation | ||
Assertions.assertEquals(117,supplier.get()); //Third invocation | ||
} | ||
|
||
/** | ||
* Test of {@link Suppliers#fixInAdvance(Supplier)}. | ||
*/ | ||
@Test | ||
void fixInAdvance() { | ||
Supplier<Integer> source=()->117; | ||
Supplier<Integer> supplier=Suppliers.fixInAdvance(source); | ||
|
||
Assertions.assertEquals(117,supplier.get()); //First invocation | ||
Assertions.assertEquals(117,supplier.get()); //Second invocation | ||
Assertions.assertEquals(117,supplier.get()); //Third invocation | ||
} | ||
|
||
/** | ||
* Test of {@link Suppliers#fixOnDemand(Supplier)}. | ||
*/ | ||
@Test | ||
void fixOnDemand() { | ||
AtomicInteger value=new AtomicInteger(0); //No value set ... yet! | ||
Supplier<Integer> source=value::get; | ||
Supplier<Integer> supplier=Suppliers.fixOnDemand(source); //If anything is executed and read here then it is not 117! | ||
value.set(117); //Now do set the number expected! | ||
|
||
Assertions.assertEquals(117,supplier.get()); //First invocation | ||
Assertions.assertEquals(117,supplier.get()); //Second invocation | ||
Assertions.assertEquals(117,supplier.get()); //Third invocation | ||
} | ||
} |