Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SANE (Public)
drasyl
Commits
9e0fc9e7
Verified
Commit
9e0fc9e7
authored
Mar 09, 2021
by
roebert
👻
Browse files
.
parent
c0e8986a
Pipeline
#56059
passed with stages
in 6 minutes and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
drasyl-core/src/main/java/org/drasyl/util/RxJavaTestUtil.java
deleted
100644 → 0
View file @
c0e8986a
/*
* Copyright (c) 2020-2021.
*
* This file is part of drasyl.
*
* drasyl is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* drasyl is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with drasyl. If not, see <http://www.gnu.org/licenses/>.
*/
package
org.drasyl.util
;
import
io.reactivex.rxjava3.observers.BaseTestConsumer
;
import
org.drasyl.annotation.NonNull
;
import
java.util.Arrays
;
import
java.util.List
;
public
final
class
RxJavaTestUtil
{
private
RxJavaTestUtil
()
{
// util class
}
/**
* Assert that the {@code TestObserver}/{@code TestSubscriber} received only the specified
* values in any order.
*
* @param values the values expected
* @return {@code baseTestConsumer}
*/
@SafeVarargs
@NonNull
public
static
<
T
,
U
extends
BaseTestConsumer
<
T
,
U
>>
U
assertValues
(
@NonNull
final
U
baseTestConsumer
,
@NonNull
final
T
...
values
)
{
final
List
<
T
>
actualValues
=
baseTestConsumer
.
values
();
final
int
s
=
actualValues
.
size
();
if
(
s
!=
values
.
length
)
{
throw
new
AssertionError
(
"Value count differs; expected: "
+
values
.
length
+
" "
+
Arrays
.
toString
(
values
)
+
" but was: "
+
s
+
" "
+
actualValues
);
}
for
(
final
T
value
:
values
)
{
if
(!
actualValues
.
contains
(
value
))
{
throw
new
AssertionError
(
"expected: "
+
U
.
valueAndClass
(
value
)
+
" but was not included"
);
}
}
return
baseTestConsumer
;
}
}
drasyl-plugin-groups-manager/src/test/java/org/drasyl/plugin/groups/manager/GroupsManagerHandlerTest.java
View file @
9e0fc9e7
...
...
@@ -45,7 +45,6 @@ import org.drasyl.plugin.groups.manager.data.Membership;
import
org.drasyl.plugin.groups.manager.database.DatabaseAdapter
;
import
org.drasyl.plugin.groups.manager.database.DatabaseException
;
import
org.drasyl.serialization.JacksonJsonSerializer
;
import
org.drasyl.util.RxJavaTestUtil
;
import
org.drasyl.util.scheduler.DrasylScheduler
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Nested
;
...
...
@@ -54,6 +53,7 @@ import org.junit.jupiter.api.Timeout;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.mockito.Mock
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
test.util.RxJavaTestUtil
;
import
java.time.Duration
;
import
java.util.Set
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment