From 0af759dc469ace385a2dd3cb1755718bfadab885 Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Mon, 9 Sep 2024 16:37:50 -0500 Subject: [PATCH] updated swiftformat rules --- ...hNotificationsPlugin+ClientBehaviour.swift | 36 +++++++++++-------- ...intPushNotificationsPlugin+Configure.swift | 16 +++++---- .../PushNotificationUserInfo+Pinpoint.swift | 3 +- ...ificationsPluginClientBehaviourTests.swift | 14 +++++--- ...ushNotificationsPluginConfigureTests.swift | 5 +-- .../ErrorPushNotificationsTests.swift | 3 +- .../Mocks/MockAWSPinpoint.swift | 7 ++-- .../PushNotificationHostAppUITests.swift | 6 ++-- 8 files changed, 53 insertions(+), 37 deletions(-) diff --git a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+ClientBehaviour.swift b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+ClientBehaviour.swift index e208a16194..2ddc96fb27 100644 --- a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+ClientBehaviour.swift +++ b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+ClientBehaviour.swift @@ -25,16 +25,20 @@ public extension AWSPinpointPushNotificationsPlugin { if let userProfile { currentEndpointProfile.addUserProfile(userProfile) } - try await pinpoint.updateEndpoint(with: currentEndpointProfile, - source: .pushNotifications) + try await pinpoint.updateEndpoint( + with: currentEndpointProfile, + source: .pushNotifications + ) } func registerDevice(apnsToken: Data) async throws { var currentEndpointProfile = await pinpoint.currentEndpointProfile() currentEndpointProfile.setAPNsToken(apnsToken) do { - try await pinpoint.updateEndpoint(with: currentEndpointProfile, - source: .pushNotifications) + try await pinpoint.updateEndpoint( + with: currentEndpointProfile, + source: .pushNotifications + ) } catch { throw error.pushNotificationsError } @@ -67,10 +71,11 @@ public extension AWSPinpointPushNotificationsPlugin { pinpoint.pinpointClient } - private func recordNotification(_ userInfo: [String: Any], - applicationState: ApplicationState, - action: PushNotification.Action) async - { + private func recordNotification( + _ userInfo: [String: Any], + applicationState: ApplicationState, + action: PushNotification.Action + ) async { let userInfo: PushNotification.UserInfo = Dictionary(uniqueKeysWithValues: userInfo.map {($0, $1)}) await recordNotification( userInfo, @@ -79,10 +84,11 @@ public extension AWSPinpointPushNotificationsPlugin { ) } - private func recordNotification(_ userInfo: PushNotification.UserInfo, - applicationState: ApplicationState, - action: PushNotification.Action) async - { + private func recordNotification( + _ userInfo: PushNotification.UserInfo, + applicationState: ApplicationState, + action: PushNotification.Action + ) async { // Retrieve the payload from the notification guard let payload = userInfo.payload else { log.error( @@ -101,8 +107,10 @@ public extension AWSPinpointPushNotificationsPlugin { // Add application state let applicationStateAttribute = applicationState.pinpointAttribute - pushNotificationEvent.addAttribute(applicationStateAttribute.value, - forKey: applicationStateAttribute.key) + pushNotificationEvent.addAttribute( + applicationStateAttribute.value, + forKey: applicationStateAttribute.key + ) // Set global remote attributes await pinpoint.setRemoteGlobalAttributes(payload.attributes) diff --git a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+Configure.swift b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+Configure.swift index ba30eae275..3a4f9e04de 100644 --- a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+Configure.swift +++ b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/AWSPinpointPushNotificationsPlugin+Configure.swift @@ -31,7 +31,8 @@ extension AWSPinpointPushNotificationsPlugin { pluginConfiguration = AWSPinpointPluginConfiguration( appId: notifications.amazonPinpointAppId, - region: notifications.awsRegion) + region: notifications.awsRegion + ) } else if let config = configuration as? JSONValue { pluginConfiguration = try AWSPinpointPluginConfiguration(config) } else { @@ -51,8 +52,10 @@ extension AWSPinpointPushNotificationsPlugin { region: configuration.region ) - configure(pinpoint: pinpoint, - remoteNotificationsHelper: .default) + configure( + pinpoint: pinpoint, + remoteNotificationsHelper: .default + ) } private func requestNotificationsPermissions(using helper: RemoteNotificationsBehaviour) async { @@ -70,9 +73,10 @@ extension AWSPinpointPushNotificationsPlugin { // MARK: Internal /// Internal configure method to set the properties of the plugin - func configure(pinpoint: AWSPinpointBehavior, - remoteNotificationsHelper: RemoteNotificationsBehaviour) - { + func configure( + pinpoint: AWSPinpointBehavior, + remoteNotificationsHelper: RemoteNotificationsBehaviour + ) { self.pinpoint = pinpoint Task { await remoteNotificationsHelper.registerForRemoteNotifications() diff --git a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Extensions/PushNotificationUserInfo+Pinpoint.swift b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Extensions/PushNotificationUserInfo+Pinpoint.swift index 1659bbcfdf..3b489021cf 100644 --- a/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Extensions/PushNotificationUserInfo+Pinpoint.swift +++ b/AmplifyPlugins/Notifications/Push/Sources/AWSPinpointPushNotificationsPlugin/Extensions/PushNotificationUserInfo+Pinpoint.swift @@ -35,8 +35,7 @@ extension PushNotification.UserInfo { var deeplinkUrl: URL? { if let urlString = root?[Constants.Keys.deeplink] as? String, - let deeplinkUrl = URL(string: urlString) - { + let deeplinkUrl = URL(string: urlString) { return deeplinkUrl } return nil diff --git a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginClientBehaviourTests.swift b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginClientBehaviourTests.swift index 3d11e66d0f..4da8c608b8 100644 --- a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginClientBehaviourTests.swift +++ b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginClientBehaviourTests.swift @@ -15,8 +15,10 @@ import XCTest class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNotificationsPluginTestBase { override func setUp() async throws { try await super.setUp() - plugin.configure(pinpoint: mockPinpoint, - remoteNotificationsHelper: mockRemoteNotifications) + plugin.configure( + pinpoint: mockPinpoint, + remoteNotificationsHelper: mockRemoteNotifications + ) } // MARK: - Identify User tests @@ -254,9 +256,11 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot case "notification": return UNNotification(coder: self) as Any case "request": - return UNNotificationRequest(identifier: "identifier", - content: UNNotificationContent(coder: self)!, - trigger: nil) + return UNNotificationRequest( + identifier: "identifier", + content: UNNotificationContent(coder: self)!, + trigger: nil + ) case "userInfo": return userInfo default: diff --git a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginConfigureTests.swift b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginConfigureTests.swift index 5935e3749b..a4a2103247 100644 --- a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginConfigureTests.swift +++ b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/AWSPinpointPushNotificationsPluginConfigureTests.swift @@ -178,7 +178,7 @@ class AWSPinpointPushNotificationsPluginConfigureTests: AWSPinpointPushNotificat let pinpointConfiguration = JSONValue( dictionaryLiteral: (AWSPinpointPluginConfiguration.appIdConfigKey, appId), - (AWSPinpointPluginConfiguration.regionConfigKey, region) + (AWSPinpointPluginConfiguration.regionConfigKey, region) ) return pinpointConfiguration @@ -188,6 +188,7 @@ class AWSPinpointPushNotificationsPluginConfigureTests: AWSPinpointPushNotificat .init(notifications: .init( awsRegion: testRegion, amazonPinpointAppId: testAppId, - channels: [.apns])) + channels: [.apns] + )) } } diff --git a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/ErrorPushNotificationsTests.swift b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/ErrorPushNotificationsTests.swift index 1b40789f40..309a93a76f 100644 --- a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/ErrorPushNotificationsTests.swift +++ b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/ErrorPushNotificationsTests.swift @@ -81,7 +81,8 @@ extension ErrorPushNotificationsTests { /// Then: A .unknown error is returned func testPushNotificationError_withUnknownAWSHTTPServiceError_shouldReturnUnknownError() { let error = UnknownAWSHTTPServiceError( - httpResponse: .init(body: .empty, statusCode: .accepted), message: "UnknownAWSHTTPServiceError", requestID: nil, typeName: nil) + httpResponse: .init(body: .empty, statusCode: .accepted), message: "UnknownAWSHTTPServiceError", requestID: nil, typeName: nil + ) let pushNotificationsError = error.pushNotificationsError switch pushNotificationsError { case .unknown(let errorDescription, let underlyingError): diff --git a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/Mocks/MockAWSPinpoint.swift b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/Mocks/MockAWSPinpoint.swift index cd0bd94607..0064daa992 100644 --- a/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/Mocks/MockAWSPinpoint.swift +++ b/AmplifyPlugins/Notifications/Push/Tests/AWSPinpointPushNotificationsPluginUnitTests/Mocks/MockAWSPinpoint.swift @@ -48,9 +48,10 @@ class MockAWSPinpoint: AWSPinpointBehavior { var updateEndpointCount = 0 var updatedPinpointEndpointProfile: PinpointEndpointProfile? - func updateEndpoint(with endpointProfile: PinpointEndpointProfile, - source: AWSPinpointSource) async throws - { + func updateEndpoint( + with endpointProfile: PinpointEndpointProfile, + source: AWSPinpointSource + ) async throws { updateEndpointCount += 1 updatedPinpointEndpointProfile = endpointProfile } diff --git a/AmplifyPlugins/Notifications/Push/Tests/PushNotificationHostApp/PushNotificationHostAppUITests/PushNotificationHostAppUITests.swift b/AmplifyPlugins/Notifications/Push/Tests/PushNotificationHostApp/PushNotificationHostAppUITests/PushNotificationHostAppUITests.swift index 98b128849d..7533bf6abb 100644 --- a/AmplifyPlugins/Notifications/Push/Tests/PushNotificationHostApp/PushNotificationHostAppUITests/PushNotificationHostAppUITests.swift +++ b/AmplifyPlugins/Notifications/Push/Tests/PushNotificationHostApp/PushNotificationHostAppUITests/PushNotificationHostAppUITests.swift @@ -77,8 +77,7 @@ final class PushNotificationHostAppUITests: XCTestCase { let firstAlert = firstAlertElement() if !firstAlert.waitForExistence(timeout: timeout) || - !anyElementContains(text: "Identified User", scope: firstAlert).waitForExistence(timeout: timeout) - { + !anyElementContains(text: "Identified User", scope: firstAlert).waitForExistence(timeout: timeout) { XCTFail("Failed to identify user") } } @@ -102,8 +101,7 @@ final class PushNotificationHostAppUITests: XCTestCase { let firstAlert = firstAlertElement() if !firstAlert.waitForExistence(timeout: timeout) || - !anyElementContains(text: "Registered Device", scope: firstAlert).waitForExistence(timeout: timeout) - { + !anyElementContains(text: "Registered Device", scope: firstAlert).waitForExistence(timeout: timeout) { XCTFail("Failed to register device") } }