Skip to content

Commit

Permalink
fixed: ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
bloco committed Mar 1, 2022
1 parent 455929f commit 70abe07
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class NotifyEndpointsTest {

whenever(getEndpointReceiver.get(any())).thenReturn(".Receiver")

notifyEndpoints.notifyApp(listOf(endpoint1, endpoint2), EndpointNotifyAction.ParcelToReceive)
notifyEndpoints.notifyApp(
listOf(endpoint1, endpoint2),
EndpointNotifyAction.ParcelToReceive
)

verify(context, times(2)).sendBroadcast(
check {
Expand All @@ -64,7 +67,10 @@ class NotifyEndpointsTest {

whenever(getEndpointReceiver.get(any())).thenReturn(".Receiver")

notifyEndpoints.notifyApp(listOf(endpoint, endpoint), EndpointNotifyAction.ParcelToReceive)
notifyEndpoints.notifyApp(
listOf(endpoint, endpoint),
EndpointNotifyAction.ParcelToReceive
)

verify(context, times(1)).sendBroadcast(
check {
Expand Down Expand Up @@ -106,7 +112,10 @@ class NotifyEndpointsTest {
fun notify_withUnknownAddress() {
runBlocking {
whenever(getEndpointReceiver.get(any())).thenReturn(null)
notifyEndpoints.notifyApp(LocalEndpointFactory.build(), EndpointNotifyAction.ParcelToReceive)
notifyEndpoints.notifyApp(
LocalEndpointFactory.build(),
EndpointNotifyAction.ParcelToReceive
)
verify(context, never()).sendBroadcast(any(), any())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import tech.relaycorp.gateway.background.ConnectionState
import tech.relaycorp.gateway.background.ConnectionStateObserver
import tech.relaycorp.gateway.common.Logging.logger
import tech.relaycorp.gateway.data.disk.CargoStorage
import tech.relaycorp.gateway.domain.endpoint.NotifyEndpoints
import tech.relaycorp.gateway.domain.endpoint.NotifyEndpointsOfParcels
import tech.relaycorp.relaynet.cogrpc.client.CogRPCClient
import java.util.logging.Level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RotateCertificate @Inject constructor(
private val localConfig: LocalConfig,
private val publicGatewayPreferences: PublicGatewayPreferences,
private val notifyEndpoints: NotifyEndpointsOfRenewCertificate
) {
) {

suspend operator fun invoke(certRotationSerialized: ByteArray) {
val certRotation = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class NotifyEndpoints
fun notifyApp(localEndpoint: LocalEndpoint, endpointNotifyAction: EndpointNotifyAction) {
val receiverName = getEndpointReceiver.get(localEndpoint.applicationId) ?: run {
logger.warning(
"Failed to notify ${localEndpoint.applicationId} about ${endpointNotifyAction.name} (receiver not found)"
"Failed to notify ${localEndpoint.applicationId} " +
"about ${endpointNotifyAction.name} (receiver not found)"
)
return@notifyApp
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import tech.relaycorp.gateway.data.model.MessageAddress
import tech.relaycorp.gateway.data.model.RecipientLocation
import tech.relaycorp.gateway.domain.LocalConfig
import tech.relaycorp.gateway.domain.StoreParcel
import tech.relaycorp.gateway.domain.endpoint.NotifyEndpoints
import tech.relaycorp.gateway.domain.endpoint.NotifyEndpointsOfParcels
import tech.relaycorp.gateway.pdc.PoWebClientProvider
import tech.relaycorp.relaynet.bindings.pdc.ClientBindingException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RegisterGateway
) {

suspend fun registerIfNeeded(): Result {
val registrationInitialState = publicGatewayPreferences.getRegistrationState()
val registrationInitialState = publicGatewayPreferences.getRegistrationState()

if (
registrationInitialState != RegistrationState.ToDo &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@ class NotifyEndpointsOfParcelsTest {
useCase.notifyAllPending()

// Assert
verify(localEndpointDao).list(check {
assertEquals(2, it.size)
})
verify(localEndpointDao).list(
check {
assertEquals(2, it.size)
}
)
verify(notifyEndpoints).notifyApp(
listOf(endpoint1, endpoint2),
EndpointNotifyAction.ParcelToReceive
)
}

@Test
fun `Notify by message address`() = runBlockingTest{
fun `Notify by message address`() = runBlockingTest {
// Arrange
val useCase = build()
val endpoint1 = LocalEndpointFactory.build()
Expand All @@ -69,16 +71,19 @@ class NotifyEndpointsOfParcelsTest {
useCase.notify(endpoint1.address)

// Assert
verify(localEndpointDao).get(check {
assertEquals(endpoint1.address, it)
})
verify(localEndpointDao).get(
check {
assertEquals(endpoint1.address, it)
}
)
verify(notifyEndpoints).notifyApp(
endpoint1,
EndpointNotifyAction.ParcelToReceive
)
}

@Test
fun `Don't notify when theres no local address`() = runBlockingTest{
fun `Don't notify when theres no local address`() = runBlockingTest {
// Arrange
val useCase = build()
whenever(localEndpointDao.get(any())).thenReturn(null)
Expand All @@ -90,7 +95,6 @@ class NotifyEndpointsOfParcelsTest {
verify(notifyEndpoints, never()).notifyApp(any<LocalEndpoint>(), any())
}


fun build() = NotifyEndpointsOfParcels(
notifyEndpoints,
storedParcelDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ class NotifyEndpointsOfRenewCertificateTest {
notifyEndpoints,
endpointDao
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import tech.relaycorp.gateway.data.model.MessageAddress
import tech.relaycorp.gateway.data.model.RecipientLocation
import tech.relaycorp.gateway.domain.LocalConfig
import tech.relaycorp.gateway.domain.StoreParcel
import tech.relaycorp.gateway.domain.endpoint.NotifyEndpoints
import tech.relaycorp.gateway.domain.endpoint.NotifyEndpointsOfParcels
import tech.relaycorp.gateway.pdc.PoWebClientProvider
import tech.relaycorp.gateway.test.BaseDataTestCase
Expand Down

0 comments on commit 70abe07

Please sign in to comment.