Use new style switch statement
This commit is contained in:
parent
2717967d61
commit
d94c171d63
|
@ -91,100 +91,29 @@ public class AccountsHelper {
|
||||||
|
|
||||||
for (Stubbing stubbing : mockingDetails.getStubbings()) {
|
for (Stubbing stubbing : mockingDetails.getStubbings()) {
|
||||||
switch (stubbing.getInvocation().getMethod().getName()) {
|
switch (stubbing.getInvocation().getMethod().getName()) {
|
||||||
case "getUuid": {
|
case "getUuid" -> when(updatedAccount.getUuid()).thenAnswer(stubbing);
|
||||||
when(updatedAccount.getUuid()).thenAnswer(stubbing);
|
case "getPhoneNumberIdentifier" -> when(updatedAccount.getPhoneNumberIdentifier()).thenAnswer(stubbing);
|
||||||
break;
|
case "getNumber" -> when(updatedAccount.getNumber()).thenAnswer(stubbing);
|
||||||
}
|
case "getUsername" -> when(updatedAccount.getUsername()).thenAnswer(stubbing);
|
||||||
case "getPhoneNumberIdentifier": {
|
case "getDevices" -> when(updatedAccount.getDevices()).thenAnswer(stubbing);
|
||||||
when(updatedAccount.getPhoneNumberIdentifier()).thenAnswer(stubbing);
|
case "getDevice" -> when(updatedAccount.getDevice(stubbing.getInvocation().getArgument(0))).thenAnswer(stubbing);
|
||||||
break;
|
case "getMasterDevice" -> when(updatedAccount.getMasterDevice()).thenAnswer(stubbing);
|
||||||
}
|
case "isEnabled" -> when(updatedAccount.isEnabled()).thenAnswer(stubbing);
|
||||||
case "getNumber": {
|
case "isDiscoverableByPhoneNumber" -> when(updatedAccount.isDiscoverableByPhoneNumber()).thenAnswer(stubbing);
|
||||||
when(updatedAccount.getNumber()).thenAnswer(stubbing);
|
case "getNextDeviceId" -> when(updatedAccount.getNextDeviceId()).thenAnswer(stubbing);
|
||||||
break;
|
case "isGroupsV2Supported" -> when(updatedAccount.isGroupsV2Supported()).thenAnswer(stubbing);
|
||||||
}
|
case "isGv1MigrationSupported" -> when(updatedAccount.isGv1MigrationSupported()).thenAnswer(stubbing);
|
||||||
case "getUsername": {
|
case "isSenderKeySupported" -> when(updatedAccount.isSenderKeySupported()).thenAnswer(stubbing);
|
||||||
when(updatedAccount.getUsername()).thenAnswer(stubbing);
|
case "isAnnouncementGroupSupported" -> when(updatedAccount.isAnnouncementGroupSupported()).thenAnswer(stubbing);
|
||||||
break;
|
case "isChangeNumberSupported" -> when(updatedAccount.isChangeNumberSupported()).thenAnswer(stubbing);
|
||||||
}
|
case "isPniSupported" -> when(updatedAccount.isPniSupported()).thenAnswer(stubbing);
|
||||||
case "getDevices": {
|
case "isStoriesSupported" -> when(updatedAccount.isStoriesSupported()).thenAnswer(stubbing);
|
||||||
when(updatedAccount.getDevices())
|
case "isGiftBadgesSupported" -> when(updatedAccount.isGiftBadgesSupported()).thenAnswer(stubbing);
|
||||||
.thenAnswer(stubbing);
|
case "getEnabledDeviceCount" -> when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing);
|
||||||
break;
|
case "getRegistrationLock" -> when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing);
|
||||||
}
|
case "getIdentityKey" -> when(updatedAccount.getIdentityKey()).thenAnswer(stubbing);
|
||||||
case "getDevice": {
|
case "getBadges" -> when(updatedAccount.getBadges()).thenAnswer(stubbing);
|
||||||
when(updatedAccount.getDevice(stubbing.getInvocation().getArgument(0)))
|
default -> throw new IllegalArgumentException("unsupported method: Account#" + stubbing.getInvocation().getMethod().getName());
|
||||||
.thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "getMasterDevice": {
|
|
||||||
when(updatedAccount.getMasterDevice()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isEnabled": {
|
|
||||||
when(updatedAccount.isEnabled()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isDiscoverableByPhoneNumber": {
|
|
||||||
when(updatedAccount.isDiscoverableByPhoneNumber()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "getNextDeviceId": {
|
|
||||||
when(updatedAccount.getNextDeviceId()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isGroupsV2Supported": {
|
|
||||||
when(updatedAccount.isGroupsV2Supported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isGv1MigrationSupported": {
|
|
||||||
when(updatedAccount.isGv1MigrationSupported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isSenderKeySupported": {
|
|
||||||
when(updatedAccount.isSenderKeySupported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isAnnouncementGroupSupported": {
|
|
||||||
when(updatedAccount.isAnnouncementGroupSupported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isChangeNumberSupported": {
|
|
||||||
when(updatedAccount.isChangeNumberSupported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isPniSupported": {
|
|
||||||
when(updatedAccount.isPniSupported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isStoriesSupported": {
|
|
||||||
when(updatedAccount.isStoriesSupported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "isGiftBadgesSupported": {
|
|
||||||
when(updatedAccount.isGiftBadgesSupported()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "getEnabledDeviceCount": {
|
|
||||||
when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "getRegistrationLock": {
|
|
||||||
when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "getIdentityKey": {
|
|
||||||
when(updatedAccount.getIdentityKey()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "getBadges": {
|
|
||||||
when(updatedAccount.getBadges()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"unsupported method: Account#" + stubbing.getInvocation().getMethod().getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue