diff --git a/pom.xml b/pom.xml index 5e60fa6..6aceccf 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 ua.net.uid uid.tools - 1.0.2-SNAPSHOT + 1.0.3-SNAPSHOT jar @@ -99,34 +99,34 @@ uid-releases - - - ua.net.uid-releases - https://git.uid.net.ua/maven/releases/ - - - ua.net.uid-snapshots - https://git.uid.net.ua/maven/snapshots/ - - - scm:git:https://git.uid.net.ua/git/uid/uid.tools.git scm:git:https://git.uid.net.ua/git/uid/uid.tools.git https://git.uid.net.ua/git/uid/uid.tools.git - HEAD - - + HEAD + + + + + uid-gitbucket-maven-repository-releases + https://git.uid.net.ua/maven/releases/ + + + uid-gitbucket-maven-repository-snapshots + https://git.uid.net.ua/maven/snapshots/ + + + - uid-releases + uid-gitbucket-maven-repository-releases Release repository https://git.uid.net.ua/maven/releases/ - uid-snapshots + uid-gitbucket-maven-repository-snapshots Snapshots repository https://git.uid.net.ua/maven/snapshots/ - + \ No newline at end of file diff --git a/src/main/java/ua/net/uid/utils/concurrent/Promise.java b/src/main/java/ua/net/uid/utils/concurrent/Promise.java new file mode 100644 index 0000000..556c5f3 --- /dev/null +++ b/src/main/java/ua/net/uid/utils/concurrent/Promise.java @@ -0,0 +1,373 @@ +/* + * Copyright 2020 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ua.net.uid.utils.concurrent; + +import java.util.Queue; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinTask; +import ua.net.uid.utils.Function; + +/** + * !WIP! not for use + * + * @author nightfall + * @param + */ +public class Promise { + //////////////////////////////////////////////////////////////////////////// + public enum State { PENDING, FULFILLED, REJECTED } + //////////////////////////////////////////////////////////////////////////// + public interface Resolver { + void accept(V value); + void reject(Throwable error); + } + public interface Performer { + void apply(Resolver resolver) throws Throwable; + } + //////////////////////////////////////////////////////////////////////////// + public static Promise resolve(V value) { + return new Promise<>(value, 0); + } + public static Promise reject(Throwable error) { + return new Promise<>(error, false); + } + //////////////////////////////////////////////////////////////////////////// + /* + public static Promise> all(Promise ... promises) { + return all(Arrays.asList(promises)); + } + public static Promise> all(Iterable> promises) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + public static Promise> allSettled(Promise ... promises) { + return allSettled(Arrays.asList(promises)); + } + public static Promise> allSettled(Iterable> promises) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + public static Promise> any(Promise ... promises) { + return any(Arrays.asList(promises)); + } + public static Promise> any(Iterable> promises) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + public static Promise> race(Promise ... promises) { + return race(Arrays.asList(promises)); + } + public static Promise> race(Iterable> promises) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + */ + //////////////////////////////////////////////////////////////////////////// + private volatile Internal internal; + //////////////////////////////////////////////////////////////////////////// + private Promise(V value, int any) { + internal = new Fulfilled(value); + } + private Promise(Throwable error, boolean any) { + internal = new Rejected(error); + } + + public Promise(Callable task) { + this((resolver) -> { + try { + resolver.accept(task.call()); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + } + public Promise(Performer performer) { + internal = new Pending(performer); + internal.run(); + } + //////////////////////////////////////////////////////////////////////////// + public State getState() { + return internal.getState(); + } + public V getValue() { + internal.sync(); + return internal.getValue(); + } + public Throwable getError() { + internal.sync(); + return internal.getError(); + } + public Promise sync() { + internal.sync(); + return this; + } + public Promise then(Function callback) { + return internal.then(callback); + } + public Promise then(U value) { + return internal.then(value); + } + public Promise except(Function callback) { + return internal.except(callback); + } + public Promise except(U value) { + return internal.except(value); + } + public Promise anyway(Function callback) { + return internal.anyway(callback); + } + public Promise anyway(U value) { + return internal.anyway(value); + } + private void run() { + internal.run(); + } + //////////////////////////////////////////////////////////////////////////// + private interface Internal { + State getState(); + V getValue(); + Throwable getError(); + void run(); + void sync(); + Promise then(Function callback); + Promise then(U value); + Promise except(Function callback); + Promise except(U value); + Promise anyway(Function callback); + Promise anyway(U value); + } + //////////////////////////////////////////////////////////////////////////// + private final class Fulfilled implements Internal { + private final V value; + public Fulfilled(V value) { this.value = value; } + @Override + public State getState() { return State.FULFILLED; } + @Override + public V getValue() { return value; } + @Override + public Throwable getError() { return null; } + @Override + public void run() {} + @Override + public void sync() {} + + @Override + public Promise then(Function callback) { + return new Promise<>((resolver) -> { + try { + resolver.accept(callback.call(value)); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + } + @Override + public Promise then(U value) { + return Promise.resolve(value); + } + @Override + public Promise except(Function callback) { + return (Promise) Promise.this; + } + @Override + public Promise except(U value) { + return (Promise) Promise.this; + } + @Override + public Promise anyway(Function callback) { + return new Promise<>((resolver) -> { + try { + resolver.accept(callback.call(value)); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + } + @Override + public Promise anyway(U value) { + return Promise.resolve(value); + } + } + //////////////////////////////////////////////////////////////////////////// + private final class Rejected implements Internal { + private final Throwable error; + public Rejected(Throwable error) { this.error = error; } + @Override + public State getState() { return State.REJECTED; } + @Override + public V getValue() { return null; } + @Override + public Throwable getError() { return error; } + @Override + public void run() {} + @Override + public void sync() {} + + @Override + public Promise then(Function callback) { + return (Promise) Promise.this; + } + @Override + public Promise then(U value) { + return (Promise) Promise.this; + } + @Override + public Promise except(Function callback) { + return new Promise<>((resolver) -> { + try { + resolver.accept(callback.call(error)); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + } + @Override + public Promise except(U value) { + return Promise.resolve(value); + } + @Override + public Promise anyway(Function callback) { + return new Promise<>((resolver) -> { + try { + resolver.accept(callback.call(error)); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + } + @Override + public Promise anyway(U value) { + return Promise.resolve(value); + } + } + //////////////////////////////////////////////////////////////////////////// + private final class Pending implements Internal, Resolver { + private final ForkJoinTask task; + private final Queue onFulfill = new ConcurrentLinkedQueue<>(); + private final Queue onReject = new ConcurrentLinkedQueue<>(); + private Object value = null; + public Pending(Performer performer) { + task = ForkJoinTask.adapt(() -> { + try { + performer.apply(Pending.this); + } catch (Throwable error) { + Pending.this.reject(error); + } + }); + } + @Override + public State getState() { return State.PENDING; } + @Override + public V getValue() { throw new UnsupportedOperationException(); } + @Override + public Throwable getError() { throw new UnsupportedOperationException(); } + @Override + public void run() { + ForkJoinPool.commonPool().submit(task); + } + @Override + public void sync() { + try { + task.get(); + } catch (InterruptedException | ExecutionException ex) { + reject(ex); + } + } + @Override + public Promise then(Function callback) { + Promise promise = new Promise<>((resolver) -> { + try { + resolver.accept(callback.call((V) Pending.this.value)); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + onFulfill.add(promise); + return promise; + } + @Override + public Promise then(U value) { + Promise promise = Promise.resolve(value); + onFulfill.add(promise); + return promise; + } + @Override + public Promise except(Function callback) { + Promise promise = new Promise<>((resolver) -> { + try { + resolver.accept(callback.call((Throwable) Pending.this.value)); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + onReject.add(promise); + return promise; + } + @Override + public Promise except(U value) { + Promise promise = Promise.resolve(value); + onReject.add(promise); + return promise; + } + @Override + public Promise anyway(Function callback) { + Promise promise = new Promise<>((resolver) -> { + try { + resolver.accept(callback.call(Pending.this.value)); + } catch (Throwable ex) { + resolver.reject(ex); + } + }); + onFulfill.add(promise); + onReject.add(promise); + return promise; + } + @Override + public Promise anyway(U value) { + Promise promise = Promise.resolve(value); + onFulfill.add(promise); + onReject.add(promise); + return promise; + } + @Override + public void accept(V value) { + internal = new Fulfilled(value); + this.value = value; + if (!onFulfill.isEmpty()) { + ForkJoinPool.commonPool().execute(() -> { + do { + onFulfill.peek().run(); + } while (!onFulfill.isEmpty()); + }); + } + } + @Override + public void reject(Throwable error) { + internal = new Rejected(error); + this.value = error; + if (!onReject.isEmpty()) { + ForkJoinPool.commonPool().execute(() -> { + do { + onReject.peek().run(); + } while (!onReject.isEmpty()); + }); + } + } + } + //////////////////////////////////////////////////////////////////////////// +} diff --git a/src/main/java/ua/net/uid/utils/helpers/Cast.java b/src/main/java/ua/net/uid/utils/helpers/Cast.java index e62b3a9..fb4ba41 100644 --- a/src/main/java/ua/net/uid/utils/helpers/Cast.java +++ b/src/main/java/ua/net/uid/utils/helpers/Cast.java @@ -29,6 +29,10 @@ private Cast() { } + + public static String toString(final Object value, String defaults) { + return CommonHelper.isEmpty(value) ? defaults : value.toString(); + } public static Boolean toBoolean(final String text, Boolean defaults) { if (text != null) { diff --git a/src/main/java/ua/net/uid/utils/helpers/NumberHelper.java b/src/main/java/ua/net/uid/utils/helpers/NumberHelper.java index 93137f6..8ff7b4a 100644 --- a/src/main/java/ua/net/uid/utils/helpers/NumberHelper.java +++ b/src/main/java/ua/net/uid/utils/helpers/NumberHelper.java @@ -302,11 +302,11 @@ } } position.setIndex(end); - return smallest(value); + return value; } } position.setIndex(end); - return (byte)0; + return 0L; } private static Number nextHexNumeric(CharSequence source, ParsePosition position, int end, int length) { @@ -370,7 +370,7 @@ } return (double)main * Math.pow(2, base); } else { - return smallest(main); + return main; } } position.setErrorIndex(end); @@ -392,7 +392,7 @@ ++end; } position.setIndex(end); - return smallest(value); + return value; } } position.setErrorIndex(end); @@ -422,7 +422,7 @@ if (real) { return (double)main * Math.pow(10, base); } else { - return smallest(main); + return main; } } diff --git a/src/main/java/ua/net/uid/utils/time/DailyEquation.java b/src/main/java/ua/net/uid/utils/time/DailyEquation.java index 5bbcd95..5d5bc9f 100644 --- a/src/main/java/ua/net/uid/utils/time/DailyEquation.java +++ b/src/main/java/ua/net/uid/utils/time/DailyEquation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.time; import java.util.Calendar; diff --git a/src/main/java/ua/net/uid/utils/time/DailyEventType.java b/src/main/java/ua/net/uid/utils/time/DailyEventType.java index 26bab43..9bf3739 100644 --- a/src/main/java/ua/net/uid/utils/time/DailyEventType.java +++ b/src/main/java/ua/net/uid/utils/time/DailyEventType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.time; public enum DailyEventType { diff --git a/src/main/java/ua/net/uid/utils/time/DailyEvents.java b/src/main/java/ua/net/uid/utils/time/DailyEvents.java index e75ba4e..755ea78 100644 --- a/src/main/java/ua/net/uid/utils/time/DailyEvents.java +++ b/src/main/java/ua/net/uid/utils/time/DailyEvents.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.time; import java.util.Objects; diff --git a/src/main/java/ua/net/uid/utils/time/Zenith.java b/src/main/java/ua/net/uid/utils/time/Zenith.java index 5317e8d..7eaf66b 100644 --- a/src/main/java/ua/net/uid/utils/time/Zenith.java +++ b/src/main/java/ua/net/uid/utils/time/Zenith.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.time; public enum Zenith { diff --git a/src/test/java/ua/net/uid/utils/concurrent/PromiseTest.java b/src/test/java/ua/net/uid/utils/concurrent/PromiseTest.java new file mode 100644 index 0000000..640bfdb --- /dev/null +++ b/src/test/java/ua/net/uid/utils/concurrent/PromiseTest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2020 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ua.net.uid.utils.concurrent; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +/** + * + * @author nightfall + */ +public class PromiseTest { + + public PromiseTest() { + } + + @Test + public void testResolveState() { + Promise promise = Promise.resolve(123); + assertSame(Promise.State.FULFILLED, promise.getState()); + + assertEquals(Integer.valueOf(123), promise.getValue()); + assertNull(promise.getError()); + } + + @Test + public void testRejectState() { + final Throwable error = new UnsupportedOperationException("test exception #1"); + Promise promise = Promise.reject(error); + assertSame(Promise.State.REJECTED, promise.getState()); + + assertNull(promise.getValue()); + assertEquals(error, promise.getError()); + } + + @Test + public void testPendingState() { + Exception error = new UnsupportedOperationException("test throw"); + + Promise promise1 = new Promise<>(() -> { + Thread.sleep(1); + return 213; + }); + Promise promise2 = new Promise<>(() -> { + Thread.sleep(1); + throw error; + }); + + assertSame(Promise.State.PENDING, promise1.getState()); + assertSame(Promise.State.PENDING, promise2.getState()); + + assertEquals(Integer.valueOf(213), promise1.getValue()); + assertNull(promise1.getError()); + assertSame(Promise.State.FULFILLED, promise1.getState()); + + assertNull(promise2.getValue()); + assertEquals(error, promise2.getError()); + assertSame(Promise.State.REJECTED, promise2.getState()); + } + + + + + + + + + +} diff --git a/src/test/java/ua/net/uid/utils/concurrent/ReadyFutureTest.java b/src/test/java/ua/net/uid/utils/concurrent/ReadyFutureTest.java index 67975cf..6c6c1b6 100644 --- a/src/test/java/ua/net/uid/utils/concurrent/ReadyFutureTest.java +++ b/src/test/java/ua/net/uid/utils/concurrent/ReadyFutureTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.concurrent; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/ArrayHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/ArrayHelperTest.java index a7e1147..eccb703 100644 --- a/src/test/java/ua/net/uid/utils/helpers/ArrayHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/ArrayHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/CastTest.java b/src/test/java/ua/net/uid/utils/helpers/CastTest.java index a76294e..4114035 100644 --- a/src/test/java/ua/net/uid/utils/helpers/CastTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/CastTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/CharsetHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/CharsetHelperTest.java index 5e98a44..fd6bf56 100644 --- a/src/test/java/ua/net/uid/utils/helpers/CharsetHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/CharsetHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/CommonHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/CommonHelperTest.java index f5423c2..3011868 100644 --- a/src/test/java/ua/net/uid/utils/helpers/CommonHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/CommonHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/EnumHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/EnumHelperTest.java index a610878..1c57c14 100644 --- a/src/test/java/ua/net/uid/utils/helpers/EnumHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/EnumHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import java.util.Arrays; diff --git a/src/test/java/ua/net/uid/utils/helpers/IOHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/IOHelperTest.java index fe5d7dd..2d0b549 100644 --- a/src/test/java/ua/net/uid/utils/helpers/IOHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/IOHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/NumberHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/NumberHelperTest.java index 219b3f6..c26fd53 100644 --- a/src/test/java/ua/net/uid/utils/helpers/NumberHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/NumberHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; @@ -89,19 +104,19 @@ "0 0x0 0x7a 0x1f9c 0x00000ffffff 0x10000ffffff 0x0. 0x7.a 0x1f.9c 0x00000.ffffff 0x10000.ffffff "+ "0x0p0 0x1000P+256 0x1000P-256 0x1.fffffffffffffp1023 0x0.0000000000001P-1022 0x1.0P-1074 0x1.8p+1"; - assertEquals((byte)0, NumberHelper.parse(source, position)); + assertEquals(0L, NumberHelper.parse(source, position)); assertEquals(1, position.getIndex()); - assertEquals((byte)0, NumberHelper.parse(source, position)); + assertEquals(0L, NumberHelper.parse(source, position)); assertEquals(5, position.getIndex()); - assertEquals((byte)0x7a, NumberHelper.parse(source, position)); + assertEquals(0x7aL, NumberHelper.parse(source, position)); assertEquals(10, position.getIndex()); - assertEquals((short)0x1f9c, NumberHelper.parse(source, position)); + assertEquals(0x1f9cL, NumberHelper.parse(source, position)); assertEquals(17, position.getIndex()); - assertEquals(0xffffff, NumberHelper.parse(source, position)); + assertEquals(0xffffffL, NumberHelper.parse(source, position)); assertEquals(31, position.getIndex()); assertEquals(0x10000ffffffL, NumberHelper.parse(source, position)); @@ -153,19 +168,19 @@ ParsePosition position = new ParsePosition(0); String source = "0 01 077 06666 01234567 0123456701234567"; - assertEquals((byte)0, NumberHelper.parse(source, position)); + assertEquals(0L, NumberHelper.parse(source, position)); assertEquals(1, position.getIndex()); - assertEquals((byte)01, NumberHelper.parse(source, position)); + assertEquals(01L, NumberHelper.parse(source, position)); assertEquals(4, position.getIndex()); - assertEquals((byte)077, NumberHelper.parse(source, position)); + assertEquals(077L, NumberHelper.parse(source, position)); assertEquals(8, position.getIndex()); - assertEquals((short)0_66_66, NumberHelper.parse(source, position)); + assertEquals(0_66_66L, NumberHelper.parse(source, position)); assertEquals(14, position.getIndex()); - assertEquals(01234567, NumberHelper.parse(source, position)); + assertEquals(01234567L, NumberHelper.parse(source, position)); assertEquals(23, position.getIndex()); assertEquals(0123456701234567L, NumberHelper.parse(source, position)); @@ -180,16 +195,16 @@ ParsePosition position = new ParsePosition(0); String source = "0b0 0b1 0b11111111 0b1111111111111111111111111111111111111111111111111111111111111111 0ba"; - assertEquals((byte)0, NumberHelper.parse(source, position)); + assertEquals(0L, NumberHelper.parse(source, position)); assertEquals(3, position.getIndex()); - assertEquals((byte)1, NumberHelper.parse(source, position)); + assertEquals(1L, NumberHelper.parse(source, position)); assertEquals(7, position.getIndex()); - assertEquals((short)0b11111111, NumberHelper.parse(source, position)); + assertEquals(0b11111111L, NumberHelper.parse(source, position)); assertEquals(18, position.getIndex()); - assertEquals((byte)-1, NumberHelper.parse(source, position)); + assertEquals(-1L, NumberHelper.parse(source, position)); assertEquals(85, position.getIndex()); assertNull(NumberHelper.parse(source, position)); @@ -203,16 +218,16 @@ ParsePosition position = new ParsePosition(0); String source = "1 333 70000 465729124123444 .01 77. 3.333 .1e-3 222.e76 123.456e-78 888e+8 "; - assertEquals((byte)1, NumberHelper.parse(source, position)); + assertEquals(1L, NumberHelper.parse(source, position)); assertEquals(1, position.getIndex()); - assertEquals((short)333, NumberHelper.parse(source, position)); + assertEquals(333L, NumberHelper.parse(source, position)); assertEquals(5, position.getIndex()); - assertEquals(70000, NumberHelper.parse(source, position)); + assertEquals(70000L, NumberHelper.parse(source, position)); assertEquals(11, position.getIndex()); - assertEquals(465729124123444l, NumberHelper.parse(source, position)); + assertEquals(465729124123444L, NumberHelper.parse(source, position)); assertEquals(27, position.getIndex()); assertEquals(.01, NumberHelper.parse(source, position)); diff --git a/src/test/java/ua/net/uid/utils/helpers/RandomHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/RandomHelperTest.java index e370374..80f68ff 100644 --- a/src/test/java/ua/net/uid/utils/helpers/RandomHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/RandomHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/RegexHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/RegexHelperTest.java index bf65a04..1e2ac9b 100644 --- a/src/test/java/ua/net/uid/utils/helpers/RegexHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/RegexHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/StringHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/StringHelperTest.java index 4880448..154fd16 100644 --- a/src/test/java/ua/net/uid/utils/helpers/StringHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/StringHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/TransliterateTest.java b/src/test/java/ua/net/uid/utils/helpers/TransliterateTest.java index fda62ce..6434184 100644 --- a/src/test/java/ua/net/uid/utils/helpers/TransliterateTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/TransliterateTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/helpers/XmlHelperTest.java b/src/test/java/ua/net/uid/utils/helpers/XmlHelperTest.java index 5c27a1f..5ab4025 100644 --- a/src/test/java/ua/net/uid/utils/helpers/XmlHelperTest.java +++ b/src/test/java/ua/net/uid/utils/helpers/XmlHelperTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.helpers; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/io/ExpiringCacheTest.java b/src/test/java/ua/net/uid/utils/io/ExpiringCacheTest.java index c76a221..8efc2df 100644 --- a/src/test/java/ua/net/uid/utils/io/ExpiringCacheTest.java +++ b/src/test/java/ua/net/uid/utils/io/ExpiringCacheTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.io; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/io/FifoCacheTest.java b/src/test/java/ua/net/uid/utils/io/FifoCacheTest.java index 8f2d5b8..9c085b2 100644 --- a/src/test/java/ua/net/uid/utils/io/FifoCacheTest.java +++ b/src/test/java/ua/net/uid/utils/io/FifoCacheTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.io; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/io/LocalCacheTest.java b/src/test/java/ua/net/uid/utils/io/LocalCacheTest.java index 39453e9..23f74f5 100644 --- a/src/test/java/ua/net/uid/utils/io/LocalCacheTest.java +++ b/src/test/java/ua/net/uid/utils/io/LocalCacheTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.io; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/io/SimpleWriterTest.java b/src/test/java/ua/net/uid/utils/io/SimpleWriterTest.java index cb6d57a..034b744 100644 --- a/src/test/java/ua/net/uid/utils/io/SimpleWriterTest.java +++ b/src/test/java/ua/net/uid/utils/io/SimpleWriterTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.io; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/iterators/AbstractFilteredIteratorTest.java b/src/test/java/ua/net/uid/utils/iterators/AbstractFilteredIteratorTest.java index e69baf2..38442ae 100644 --- a/src/test/java/ua/net/uid/utils/iterators/AbstractFilteredIteratorTest.java +++ b/src/test/java/ua/net/uid/utils/iterators/AbstractFilteredIteratorTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.iterators; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/iterators/AbstractTransformIteratorTest.java b/src/test/java/ua/net/uid/utils/iterators/AbstractTransformIteratorTest.java index cd1b955..9ffffe1 100644 --- a/src/test/java/ua/net/uid/utils/iterators/AbstractTransformIteratorTest.java +++ b/src/test/java/ua/net/uid/utils/iterators/AbstractTransformIteratorTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.iterators; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ua/net/uid/utils/iterators/ArrayIteratorTest.java b/src/test/java/ua/net/uid/utils/iterators/ArrayIteratorTest.java index 544908c..6e48f0e 100644 --- a/src/test/java/ua/net/uid/utils/iterators/ArrayIteratorTest.java +++ b/src/test/java/ua/net/uid/utils/iterators/ArrayIteratorTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.iterators; import java.util.Iterator; diff --git a/src/test/java/ua/net/uid/utils/tools/DailyEquationTest.java b/src/test/java/ua/net/uid/utils/tools/DailyEquationTest.java deleted file mode 100644 index 3c27827..0000000 --- a/src/test/java/ua/net/uid/utils/tools/DailyEquationTest.java +++ /dev/null @@ -1 +0,0 @@ -package ua.net.uid.utils.tools; diff --git a/src/test/java/ua/net/uid/utils/tools/MaskTest.java b/src/test/java/ua/net/uid/utils/tools/MaskTest.java index e9036f3..4574d4e 100644 --- a/src/test/java/ua/net/uid/utils/tools/MaskTest.java +++ b/src/test/java/ua/net/uid/utils/tools/MaskTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 nightfall. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ua.net.uid.utils.tools; import org.junit.jupiter.api.Test;