Skip to content

Commit

Permalink
Remove license from tests and fix return type
Browse files Browse the repository at this point in the history
  • Loading branch information
timyates committed Mar 8, 2024
1 parent 9d113d6 commit 5ce6c43
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 158 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.APIGatewayCustomAuthorizerEvent
import io.micronaut.serde.ObjectMapper
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class APIGatewayCustomAuthorizerEventSpec extends Specification {
@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()

JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "APIGatewayCustomAuthorizerEvent can be serialized"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent
import io.micronaut.context.BeanContext
import io.micronaut.serde.ObjectMapper
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import jakarta.inject.Inject
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class APIGatewayProxyRequestEventSpec extends Specification {
@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()

JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "APIGatewayProxyRequestEvent can be serialized"() {
given:
File f = new File("src/test/resources/api-gateway-proxy.json")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.CloudFrontEvent
import io.micronaut.serde.ObjectMapper
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class CloudFrontSimpleRemoteCallSpec extends Specification {
@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()

JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "test deserialization of cloudfront simple remote call event"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.CloudWatchLogsEvent
import io.micronaut.serde.ObjectMapper
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class CloudWatchLogsEventSpec extends Specification {

@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()
JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "test deserialization of cloud watch scheduled event"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.CodeCommitEvent
import io.micronaut.serde.ObjectMapper
import io.micronaut.json.JsonMapper
import org.joda.time.DateTime
import org.joda.time.DateTimeZone
import spock.lang.Shared
import spock.lang.Specification

class CodeCommitRepositoryEventSpec extends Specification {

@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()
JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "test deserialization of cloud watch scheduled event"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.CognitoEvent
import io.micronaut.serde.ObjectMapper
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class CognitoEventSerdeSpec extends Specification {

@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()
JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "test deserialization of cloud watch scheduled event"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.CustomPojoSerializer
import io.micronaut.json.JsonMapper
import io.micronaut.serde.ObjectMapper

import javax.naming.ConfigurationException
Expand All @@ -21,11 +22,11 @@ class CustomPojoSerializerUtils {
.orElseThrow(() -> new RuntimeException("No CustomPojoSerializer found"))
}

static ObjectMapper getObjectMapper() {
CustomPojoSerializer pojoSerializer = CustomPojoSerializerUtils.customPojoSerializer()
static JsonMapper getJsonMapper() {
CustomPojoSerializer pojoSerializer = customPojoSerializer()
if (pojoSerializer instanceof SerdeCustomPojoSerializer) {
return ((SerdeCustomPojoSerializer) pojoSerializer).getJsonMapper()
return pojoSerializer.jsonMapper
}
throw new ConfigurationException("CustomPojoSerializer no type of SerdeCustomPojoSerializer")
throw new ConfigurationException("CustomPojoSerializer is not a type of SerdeCustomPojoSerializer")
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.DynamodbEvent
import io.micronaut.serde.ObjectMapper
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class DynamodbEventSpec extends Specification {

@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()
JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "test deserialization of sqs recieve message event"() {
given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.S3Event
import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification
import io.micronaut.serde.ObjectMapper
import io.micronaut.json.JsonMapper
import spock.lang.Shared
import spock.lang.Specification

class S3EventNotificationSpec extends Specification {

@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()
JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "S3EventNotification can be serialized with s3-put"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.micronaut.aws.lambda.events.serde

import com.amazonaws.services.lambda.runtime.events.SQSEvent
import io.micronaut.serde.ObjectMapper
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class SQSReceiveMessageSpec extends Specification {

@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()
JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "test deserialization of sqs recieve message event"() {
given:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.micronaut.aws.lambda.events.serde

import io.micronaut.serde.ObjectMapper
import spock.lang.Shared
import io.micronaut.json.JsonMapper
import spock.lang.Specification

class SerializeMapsAndCollectionsSpec extends Specification {

@Shared
ObjectMapper objectMapper = CustomPojoSerializerUtils.getObjectMapper()
JsonMapper objectMapper = CustomPojoSerializerUtils.getJsonMapper()

void "Serialize map with values that are of type ArrayList"() {
given:
Expand Down

0 comments on commit 5ce6c43

Please sign in to comment.