Skip to content

Commit

Permalink
[release] release 2.0.0-alpha+002
Browse files Browse the repository at this point in the history
  • Loading branch information
VampireAchao committed Sep 7, 2023
1 parent 98863e7 commit cd26807
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 112 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<revision>2.0.0-alpha+001</revision>
<revision>2.0.0-alpha+002</revision>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-javadoc-plugin.version>3.4.0</maven-javadoc-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public interface SerPred<T> extends Predicate<T>, Serializable {
* Objects#equals(Object, Object)}.
*/
static <T> SerPred<T> isEqual(Object targetRef) {
return (null == targetRef)
? Objects::isNull
: object -> targetRef.equals(object);
return (null == targetRef) ? Objects::isNull : object -> targetRef.equals(object);
}

/** Evaluates this predicate on the given argument. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;


/** @author VampireAchao */
public class SerArgsConsTest {

Expand All @@ -34,36 +33,36 @@ void multiTest() {
Assertions.assertEquals("bar", list.get(1));
}

@Test
void testAcceptingAndAccept() {
SerArgsCons<Integer> mayThrowException = (Integer... args) -> {
if (args[0] == 0) throw new Exception("Zero");
@Test
void testAcceptingAndAccept() {
SerArgsCons<Integer> mayThrowException =
(Integer... args) -> {
if (args[0] == 0) throw new Exception("Zero");
};

Assertions.assertThrows(LambdaInvokeException.class, () -> mayThrowException.accept(0));
Assertions.assertThrows(Exception.class, () -> mayThrowException.accepting(0));
}

@Test
void testAndThen() throws Throwable {
val addOne = (SerArgsCons<Integer>) (Integer... args) -> args[0] += 1;
val addTwo = (SerArgsCons<Integer>) (Integer... args) -> args[0] += 2;
val combined = addOne.andThen(addTwo);
Assertions.assertThrows(LambdaInvokeException.class, () -> mayThrowException.accept(0));
Assertions.assertThrows(Exception.class, () -> mayThrowException.accepting(0));
}

val testArr = new Integer[]{0};
combined.accepting(testArr);
@Test
void testAndThen() throws Throwable {
val addOne = (SerArgsCons<Integer>) (Integer... args) -> args[0] += 1;
val addTwo = (SerArgsCons<Integer>) (Integer... args) -> args[0] += 2;
val combined = addOne.andThen(addTwo);

Assertions.assertEquals(3, testArr[0]);
}
val testArr = new Integer[] {0};
combined.accepting(testArr);

@Test
void testNothing() throws Throwable {
val doNothing = SerArgsCons.nothing();
Assertions.assertEquals(3, testArr[0]);
}

val testArr = new Integer[]{0};
doNothing.accepting(testArr);
@Test
void testNothing() throws Throwable {
val doNothing = SerArgsCons.nothing();

Assertions.assertEquals(0, testArr[0]);
}
val testArr = new Integer[] {0};
doNothing.accepting(testArr);

Assertions.assertEquals(0, testArr[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.dromara.streamquery.stream.core.lambda.function;

import lombok.val;
import org.dromara.streamquery.stream.core.lambda.LambdaInvokeException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand All @@ -26,67 +25,52 @@ public class SerArgsFuncTest {

@Test
void testLast() {
Assertions.assertEquals(3,
SerArgsFunc.last()
.apply(1, 2, 3)
);
Assertions.assertEquals(3, SerArgsFunc.last().apply(1, 2, 3));
}

@Test
void applyingTest() throws Throwable {
Assertions.assertEquals("foo",
((SerArgsFunc<String, String>) (String... strs) -> strs[0])
.applying("foo", "bar")
);
Assertions.assertEquals(
"foo", ((SerArgsFunc<String, String>) (String... strs) -> strs[0]).applying("foo", "bar"));
}

@Test
void applyingExceptionTest() {
Assertions.assertThrows(LambdaInvokeException.class,
() -> ((SerArgsFunc<String, String>) (String... strs) -> {
throw new Exception("Testing");
}).apply("foo")
);
Assertions.assertThrows(
LambdaInvokeException.class,
() ->
((SerArgsFunc<String, String>)
(String... strs) -> {
throw new Exception("Testing");
})
.apply("foo"));
}

@Test
void applyWithNoArgsTest() {
Assertions.assertNull(
SerArgsFunc.<String>last()
.apply()
);
Assertions.assertNull(SerArgsFunc.<String>last().apply());
}

@Test
void composeNullExceptionTest() {
Assertions.assertThrows(NullPointerException.class,
() -> SerArgsFunc.<String>last().compose(null)
);
Assertions.assertThrows(
NullPointerException.class, () -> SerArgsFunc.<String>last().compose(null));
}

@Test
void composeFunctionTest() {
Assertions.assertEquals("foobaz",
SerArgsFunc.last()
.compose(e -> e[0] + "baz")
.apply("foo", "bar")
);
Assertions.assertEquals(
"foobaz", SerArgsFunc.last().compose(e -> e[0] + "baz").apply("foo", "bar"));
}

@Test
void andThenNullExceptionTest() {
Assertions.assertThrows(NullPointerException.class,
() -> SerArgsFunc.last().andThen(null)
);
Assertions.assertThrows(NullPointerException.class, () -> SerArgsFunc.last().andThen(null));
}

@Test
void andThenTest() {
Assertions.assertEquals("bazbar",
SerArgsFunc.last()
.andThen(e -> e[0] + "bar")
.apply("foo", "baz")
);
Assertions.assertEquals(
"bazbar", SerArgsFunc.last().andThen(e -> e[0] + "bar").apply("foo", "baz"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void multiAndTest() {

@Test
void multiAndFalseTest() {
SerArgsPred<String> pred = SerArgsPred.multiAnd(e -> e[0].equals("foo"), e -> e[1].equals("baz"));
SerArgsPred<String> pred =
SerArgsPred.multiAnd(e -> e[0].equals("foo"), e -> e[1].equals("baz"));
Assertions.assertFalse(pred.test("foo", "bar"));
}

Expand All @@ -58,6 +59,7 @@ void negateTest() {
val result = SerArgsPred.isEqual("foo").negate().test("foo");
Assertions.assertFalse(result);
}

@Test
void andTest() {
val result1 = SerArgsPred.<String>isEqual("foo").and(e -> e[0].equals("foo")).test("foo");
Expand All @@ -74,7 +76,6 @@ void orTest() {
Assertions.assertFalse(result2);
}


@Test
void isEqualNullTest() {
val result = SerArgsPred.isEqual((Object[]) null).test((Object[]) null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ void multiTest() {
Assertions.assertEquals("bar", list.get(1));
}

@Test
void andThenTest() {
val list = Lists.of();
((SerBiCons<String, String>) (f, b) -> list.add(f))
.andThen((f, b) -> list.add(b))
.accept("foo", "bar");
Assertions.assertEquals("foo", list.get(0));
Assertions.assertEquals("bar", list.get(1));
}
@Test
void andThenTest() {
val list = Lists.of();
((SerBiCons<String, String>) (f, b) -> list.add(f))
.andThen((f, b) -> list.add(b))
.accept("foo", "bar");
Assertions.assertEquals("foo", list.get(0));
Assertions.assertEquals("bar", list.get(1));
}

@Test
void acceptingTest() throws Throwable {
val list = Lists.of();
((SerBiCons<String, String>) (f, b) -> list.add(f)).accepting("foo", "bar");
Assertions.assertEquals("foo", list.get(0));
}
@Test
void acceptingTest() throws Throwable {
val list = Lists.of();
((SerBiCons<String, String>) (f, b) -> list.add(f)).accepting("foo", "bar");
Assertions.assertEquals("foo", list.get(0));
}

@Test
void nothingTest() {
val list = Lists.of();
SerCons.nothing().andThen(list::add).accept("foo");
Assertions.assertEquals(1, list.size());
Assertions.assertEquals("foo", list.get(0));
}
@Test
void nothingTest() {
val list = Lists.of();
SerCons.nothing().andThen(list::add).accept("foo");
Assertions.assertEquals(1, list.size());
Assertions.assertEquals("foo", list.get(0));
}

@Test
@Test
void throwsTest() {
Assertions.assertThrows(
LambdaInvokeException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,15 @@ void entryConsTest() {
@Test
void multiTest() {
val list = Lists.of();
SerCons.<String>multi(
t -> list.add(t),
t -> list.add(t + t)
).accept("foo");
SerCons.<String>multi(t -> list.add(t), t -> list.add(t + t)).accept("foo");
Assertions.assertEquals("foo", list.get(0));
Assertions.assertEquals("foofoo", list.get(1));
}

@Test
void andThenTest() {
val list = Lists.of();
((SerCons<String>) t -> list.add(t))
.andThen(t -> list.add(t + t))
.accept("foo");
((SerCons<String>) t -> list.add(t)).andThen(t -> list.add(t + t)).accept("foo");
Assertions.assertEquals("foo", list.get(0));
Assertions.assertEquals("foofoo", list.get(1));
}
Expand All @@ -68,13 +63,13 @@ void acceptingTest() throws Throwable {
@Test
void throwsTest() {
Assertions.assertThrows(
LambdaInvokeException.class,
() -> SerCons.multi(
LambdaInvokeException.class,
() ->
SerCons.multi(
SerCons.nothing(),
t -> {
throw new Exception("test");
}
).accept("foo")
);
})
.accept("foo"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ void applyingTest() throws Throwable {

@Test
void applyingExceptionTest() {
SerFunc<String, Integer> func = s -> {
throw new Exception("Test exception");
};
SerFunc<String, Integer> func =
s -> {
throw new Exception("Test exception");
};
Assertions.assertThrows(LambdaInvokeException.class, () -> func.apply("foo"));
}

Expand All @@ -67,6 +68,4 @@ void castTest() {
Function<String, Object> castFunc = SerFunc.cast();
Assertions.assertEquals("foo", castFunc.apply("foo"));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void isEqualTest() {
val isEqualToFooOrBar = SerPred.isEqual("foo");
Assertions.assertTrue(isEqualToFooOrBar.test("foo"));
Assertions.assertFalse(isEqualToFooOrBar.test("bar"));

}

@Test
Expand All @@ -54,9 +53,10 @@ void testingTest() throws Throwable {

@Test
void testingExceptionTest() {
SerPred<String> throwException = s -> {
throw new Exception("Test exception");
};
SerPred<String> throwException =
s -> {
throw new Exception("Test exception");
};
Assertions.assertThrows(LambdaInvokeException.class, () -> throwException.test("foo"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,7 @@ public static void buildMapper(Configuration configuration, Class<?> entityClass
.build())
.name(
String.format(
"%s.%sMapper",
PluginConst.DYNAMIC_MAPPER_PREFIX, entityClass.getName()))
"%s.%sMapper", PluginConst.DYNAMIC_MAPPER_PREFIX, entityClass.getName()))
.make()
.load(ClassUtils.class.getClassLoader())
.getLoaded();
Expand Down

0 comments on commit cd26807

Please sign in to comment.