codacy: Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2023-06-01 22:27:22 +02:00
parent d4379f3c89
commit 7ad8e304e2
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
5 changed files with 31 additions and 29 deletions

View File

@ -28,12 +28,14 @@ import java.util.List;
/**
* Helper class to register and notify CallParticipantModel.Observers.
*
* <p>
* This class is only meant for internal use by CallParticipantModel; observers must register themselves against a
* CallParticipantModel rather than against a CallParticipantModelNotifier.
*/
class CallParticipantModelNotifier {
private final List<CallParticipantModelObserverOn> callParticipantModelObserversOn = new ArrayList<>();
/**
* Helper class to associate a CallParticipantModel.Observer with a Handler.
*/
@ -47,8 +49,6 @@ class CallParticipantModelNotifier {
}
}
private final List<CallParticipantModelObserverOn> callParticipantModelObserversOn = new ArrayList<>();
public synchronized void addObserver(CallParticipantModel.Observer observer, Handler handler) {
if (observer == null) {
throw new IllegalArgumentException("CallParticipantModel.Observer can not be null");

View File

@ -25,12 +25,14 @@ import java.util.List;
/**
* Helper class to register and notify CallParticipantMessageListeners.
*
* <p>
* This class is only meant for internal use by SignalingMessageReceiver; listeners must register themselves against
* a SignalingMessageReceiver rather than against a CallParticipantMessageNotifier.
*/
class CallParticipantMessageNotifier {
private final List<CallParticipantMessageListenerFrom> callParticipantMessageListenersFrom = new ArrayList<>();
/**
* Helper class to associate a CallParticipantMessageListener with a session ID.
*/
@ -45,8 +47,6 @@ class CallParticipantMessageNotifier {
}
}
private final List<CallParticipantMessageListenerFrom> callParticipantMessageListenersFrom = new ArrayList<>();
public synchronized void addListener(SignalingMessageReceiver.CallParticipantMessageListener listener, String sessionId) {
if (listener == null) {
throw new IllegalArgumentException("CallParticipantMessageListener can not be null");

View File

@ -25,12 +25,14 @@ import java.util.List;
/**
* Helper class to register and notify WebRtcMessageListeners.
*
* <p>
* This class is only meant for internal use by SignalingMessageReceiver; listeners must register themselves against
* a SignalingMessageReceiver rather than against a WebRtcMessageNotifier.
*/
class WebRtcMessageNotifier {
private final List<WebRtcMessageListenerFrom> webRtcMessageListenersFrom = new ArrayList<>();
/**
* Helper class to associate a WebRtcMessageListener with a session ID and room type.
*/
@ -48,8 +50,6 @@ class WebRtcMessageNotifier {
}
}
private final List<WebRtcMessageListenerFrom> webRtcMessageListenersFrom = new ArrayList<>();
public synchronized void addListener(SignalingMessageReceiver.WebRtcMessageListener listener, String sessionId, String roomType) {
if (listener == null) {
throw new IllegalArgumentException("WebRtcMessageListener can not be null");

View File

@ -66,6 +66,15 @@ public class CallParticipantListExternalSignalingTest {
private Collection<Participant> expectedLeft;
private Collection<Participant> expectedUnchanged;
// The order of the left participants in some tests depends on how they are internally sorted by the map, so the
// list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in
// expectedLeft).
// Other tests can just relay on the not guaranteed, but known internal sorting of the elements.
private final ArgumentMatcher<List<Participant>> matchesExpectedLeftIgnoringOrder = left -> {
Collections.sort(left, Comparator.comparing(Participant::getSessionId));
return expectedLeft.equals(left);
};
private static class ParticipantsUpdateParticipantBuilder {
private Participant newUser(long inCall, long lastPing, String sessionId, Participant.ParticipantType type,
String userId) {
@ -90,15 +99,6 @@ public class CallParticipantListExternalSignalingTest {
}
}
// The order of the left participants in some tests depends on how they are internally sorted by the map, so the
// list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in
// expectedLeft).
// Other tests can just relay on the not guaranteed, but known internal sorting of the elements.
private final ArgumentMatcher<List<Participant>> matchesExpectedLeftIgnoringOrder = left -> {
Collections.sort(left, Comparator.comparing(Participant::getSessionId));
return expectedLeft.equals(left);
};
@Before
public void setUp() {
SignalingMessageReceiver mockedSignalingMessageReceiver = mock(SignalingMessageReceiver.class);

View File

@ -58,6 +58,15 @@ public class CallParticipantListInternalSignalingTest {
private Collection<Participant> expectedLeft;
private Collection<Participant> expectedUnchanged;
// The order of the left participants in some tests depends on how they are internally sorted by the map, so the
// list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in
// expectedLeft).
// Other tests can just relay on the not guaranteed, but known internal sorting of the elements.
private final ArgumentMatcher<List<Participant>> matchesExpectedLeftIgnoringOrder = left -> {
Collections.sort(left, Comparator.comparing(Participant::getSessionId));
return expectedLeft.equals(left);
};
private static class UsersInRoomParticipantBuilder {
private Participant newUser(long inCall, long lastPing, String sessionId, String userId) {
Participant participant = new Participant();
@ -79,15 +88,6 @@ public class CallParticipantListInternalSignalingTest {
}
}
// The order of the left participants in some tests depends on how they are internally sorted by the map, so the
// list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in
// expectedLeft).
// Other tests can just relay on the not guaranteed, but known internal sorting of the elements.
private final ArgumentMatcher<List<Participant>> matchesExpectedLeftIgnoringOrder = left -> {
Collections.sort(left, Comparator.comparing(Participant::getSessionId));
return expectedLeft.equals(left);
};
@Before
public void setUp() {
SignalingMessageReceiver mockedSignalingMessageReceiver = mock(SignalingMessageReceiver.class);
@ -529,7 +529,9 @@ public class CallParticipantListInternalSignalingTest {
// Last ping is not seen as changed, even if it did.
expectedUnchanged.add(builder.newUser(IN_CALL | WITH_AUDIO, 42, "theSessionId9", "theUserId9"));
verify(mockedCallParticipantListObserver).onCallParticipantsChanged(eq(expectedJoined), eq(expectedUpdated),
argThat(matchesExpectedLeftIgnoringOrder), eq(expectedUnchanged));
verify(mockedCallParticipantListObserver).onCallParticipantsChanged(eq(expectedJoined),
eq(expectedUpdated),
argThat(matchesExpectedLeftIgnoringOrder),
eq(expectedUnchanged));
}
}