Add credentials-object-mapper as standard bean for FCM PMP
This commit is contained in:
parent
7594f4acc0
commit
f593bb27e1
|
|
@ -1,6 +1,9 @@
|
|||
package ru.touchin.push.message.provider.fcm.configurations
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.fasterxml.jackson.databind.SerializationFeature
|
||||
import com.google.auth.oauth2.AccessToken
|
||||
import com.google.auth.oauth2.GoogleCredentials
|
||||
import com.google.firebase.FirebaseApp
|
||||
|
|
@ -61,9 +64,22 @@ class PushMessageProviderFcmConfiguration {
|
|||
return FirebaseMessaging.getInstance(firebaseApp)
|
||||
}
|
||||
|
||||
@Bean("push-message-provider.fcm.auth")
|
||||
@Bean("push-message-provider.fcm.credentials-date-format")
|
||||
fun simpleDateFormat(): SimpleDateFormat {
|
||||
return SimpleDateFormat("yyyy-MM-dd HH:mm:ss X", Locale.getDefault())
|
||||
}
|
||||
|
||||
@Bean("push-message-provider.fcm.credentials-object-mapper")
|
||||
fun objectMapper(
|
||||
@Qualifier("push-message-provider.fcm.credentials-date-format")
|
||||
simpleDateFormat: SimpleDateFormat
|
||||
): ObjectMapper {
|
||||
return ObjectMapper().apply {
|
||||
configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
|
||||
setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
|
||||
setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
|
||||
dateFormat = simpleDateFormat
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import java.util.*
|
|||
@ConfigurationPropertiesBinding
|
||||
@Component
|
||||
class DateConverter(
|
||||
@Qualifier("push-message-provider.fcm.auth")
|
||||
@Qualifier("push-message-provider.fcm.credentials-date-format")
|
||||
private val simpleDateFormat: SimpleDateFormat
|
||||
) : Converter<String, Date> {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,16 @@
|
|||
package ru.touchin.push.message.provider.fcm
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.fasterxml.jackson.databind.SerializationFeature
|
||||
import com.google.firebase.FirebaseApp
|
||||
import org.springframework.beans.factory.annotation.Qualifier
|
||||
import org.springframework.boot.SpringBootConfiguration
|
||||
import org.springframework.boot.test.context.TestConfiguration
|
||||
import org.springframework.context.ApplicationListener
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.event.ContextRefreshedEvent
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
@TestConfiguration
|
||||
@SpringBootConfiguration
|
||||
@EnablePushMessageProviderFcm
|
||||
class PushMessageProviderFcmTestApplication : ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
@Bean("push-message-provider.fcm.credentials-object-mapper")
|
||||
fun objectMapper(
|
||||
@Qualifier("push-message-provider.fcm.auth")
|
||||
simpleDateFormat: SimpleDateFormat
|
||||
): ObjectMapper {
|
||||
return ObjectMapper().apply {
|
||||
configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
|
||||
setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
|
||||
setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
|
||||
dateFormat = simpleDateFormat
|
||||
}
|
||||
}
|
||||
|
||||
override fun onApplicationEvent(event: ContextRefreshedEvent) {
|
||||
clearSingletonsOutsideContainer()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue