-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for collection input and collection output rename tests for clarification what they are for
- Loading branch information
Showing
13 changed files
with
203 additions
and
84 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
.../io/quarkus/amazon/lambda/deployment/testing/AbstractInputCollectionOutputCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.amazon.lambda.deployment.testing; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
|
||
import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson; | ||
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson; | ||
|
||
public abstract class AbstractInputCollectionOutputCollection implements RequestHandler<List<InputPerson>, List<OutputPerson>> { | ||
|
||
@Override | ||
public List<OutputPerson> handleRequest(List<InputPerson> inputPeronList, Context context) { | ||
List<OutputPerson> personList = new ArrayList<>(); | ||
inputPeronList.forEach(person -> personList.add(new OutputPerson(person.getName()))); | ||
return personList; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...s/amazon/lambda/deployment/testing/AbstractInputCollectionOutputCollectionLambdaImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.quarkus.amazon.lambda.deployment.testing; | ||
|
||
public class AbstractInputCollectionOutputCollectionLambdaImpl extends AbstractInputCollectionOutputCollection { | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...azon/lambda/deployment/testing/AbstractInputCollectionOutputCollectionLambdaImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.quarkus.amazon.lambda.deployment.testing; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.hasItem; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.Matchers.hasEntry; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson; | ||
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class AbstractInputCollectionOutputCollectionLambdaImplTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest().setArchiveProducer(() -> ShrinkWrap | ||
.create(JavaArchive.class) | ||
.addClasses(AbstractInputCollectionOutputCollectionLambdaImpl.class, AbstractInputCollectionOutputCollection.class, | ||
InputPerson.class, OutputPerson.class)); | ||
|
||
@Test | ||
void abstractRequestHandler_InputCollectionInputPerson_OutputCollectionOutputPerson() { | ||
|
||
List<InputPerson> personList = new ArrayList<>(); | ||
personList.add(new InputPerson("Chris")); | ||
personList.add(new InputPerson("Fred")); | ||
|
||
given() | ||
.body(personList) | ||
.when() | ||
.post() | ||
.then() | ||
.statusCode(200) | ||
.body("", hasItem(hasEntry("outputname", "Chris"))) // OutputPerson serializes name with key outputname | ||
.body("", hasItem(hasEntry("outputname", "Fred"))) | ||
.body("", not(hasItem(hasEntry("name", "Chris")))) // make sure that there is no key name | ||
.body("", not(hasItem(hasEntry("name", "Fred")))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...va/io/quarkus/amazon/lambda/deployment/testing/InputCollectionOutputCollectionLambda.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.amazon.lambda.deployment.testing; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
|
||
import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson; | ||
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson; | ||
|
||
public class InputCollectionOutputCollectionLambda implements RequestHandler<List<InputPerson>, List<OutputPerson>> { | ||
|
||
@Override | ||
public List<OutputPerson> handleRequest(List<InputPerson> people, Context context) { | ||
|
||
List<OutputPerson> outputPeople = new ArrayList<>(); | ||
people.stream().parallel().forEach((person) -> { | ||
outputPeople.add(new OutputPerson(person.getName())); | ||
}); | ||
|
||
return outputPeople; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...o/quarkus/amazon/lambda/deployment/testing/InputCollectionOutputCollectionLambdaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.quarkus.amazon.lambda.deployment.testing; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.hasItem; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.Matchers.hasEntry; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.amazon.lambda.deployment.testing.model.InputPerson; | ||
import io.quarkus.amazon.lambda.deployment.testing.model.OutputPerson; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class InputCollectionOutputCollectionLambdaTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest().setArchiveProducer(() -> ShrinkWrap | ||
.create(JavaArchive.class) | ||
.addClasses(InputCollectionOutputCollectionLambda.class, InputPerson.class, OutputPerson.class)); | ||
|
||
@Test | ||
void requestHandler_InputCollectionInputPerson_OutputCollectionOutputPerson() { | ||
|
||
List<InputPerson> personList = new ArrayList<>(); | ||
personList.add(new InputPerson("Chris")); | ||
personList.add(new InputPerson("Fred")); | ||
|
||
given() | ||
.body(personList) | ||
.when() | ||
.post() | ||
.then() | ||
.statusCode(200) | ||
.body("", hasItem(hasEntry("outputname", "Chris"))) // OutputPerson serializes name with key outputname | ||
.body("", hasItem(hasEntry("outputname", "Fred"))) | ||
.body("", not(hasItem(hasEntry("name", "Chris")))) // make sure that there is no key name | ||
.body("", not(hasItem(hasEntry("name", "Fred")))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
...deployment/src/test/java/io/quarkus/amazon/lambda/deployment/testing/LambdaHandlerET.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...n-lambda/deployment/src/test/java/io/quarkus/amazon/lambda/deployment/testing/Person.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...eployment/src/test/java/io/quarkus/amazon/lambda/deployment/testing/PersonListLambda.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...ployment/src/test/java/io/quarkus/amazon/lambda/deployment/testing/model/InputPerson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.quarkus.amazon.lambda.deployment.testing.model; | ||
|
||
public class InputPerson { | ||
|
||
public InputPerson() { | ||
} | ||
|
||
public InputPerson(String name) { | ||
this.name = name; | ||
} | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public InputPerson setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...loyment/src/test/java/io/quarkus/amazon/lambda/deployment/testing/model/OutputPerson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.amazon.lambda.deployment.testing.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class OutputPerson { | ||
|
||
public OutputPerson() { | ||
} | ||
|
||
public OutputPerson(String name) { | ||
this.name = name; | ||
} | ||
|
||
@JsonProperty("outputname") | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |