Skip to content

Commit

Permalink
Added QueueOutputPOJOList E2E test (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
pragnagopa authored Oct 31, 2018
1 parent eab1b74 commit 5786b8b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,4 @@ pkg/
/.recommenders/*
/Azure.Functions.Cli.zip
/Azure.Functions.Cli/
/version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -63,5 +66,20 @@ public async Task QueueTrigger_QueueOutput_POJO_Succeeds()
var queueMessage = await StorageHelpers.ReadFromQueue(Constants.OutputBindingQueueNamePOJO);
Assert.Contains(expectedQueueMessage, queueMessage);
}

[Fact]
public async Task QueueOutput_POJOList_Succeeds()
{
string expectedQueueMessage = Guid.NewGuid().ToString();
//Clear queue
await StorageHelpers.ClearQueue(Constants.OutputBindingQueueNamePOJO);

//Trigger
Assert.True(await Utilities.InvokeHttpTrigger("QueueOutputPOJOList", $"?queueMessageId={expectedQueueMessage}", HttpStatusCode.OK, expectedQueueMessage));

//Verify
IEnumerable<string> queueMessages = await StorageHelpers.ReadMessagesFromQueue(Constants.OutputBindingQueueNamePOJO);
Assert.True(queueMessages.All(msg => msg.Contains(expectedQueueMessage)));
}
}
}
6 changes: 3 additions & 3 deletions endtoendtests/extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ public void queuetriggerandoutput(
output.setValue(message);
}

@FunctionName("QueueOutputPOJOList")
public HttpResponseMessage QueueOutputPOJOList(@HttpTrigger(name = "req", methods = { HttpMethod.GET,
HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@QueueOutput(name = "output", queueName = "test-output-java-pojo", connection = "AzureWebJobsStorage") OutputBinding<List<TestData>> itemsOut,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request.");

String query = request.getQueryParameters().get("queueMessageId");
String queueMessageId = request.getBody().orElse(query);
itemsOut.setValue(new ArrayList<TestData>());
if (queueMessageId != null) {
TestData testData1 = new TestData();
testData1.id = "msg1"+queueMessageId;
TestData testData2 = new TestData();
testData2.id = "msg2"+queueMessageId;

itemsOut.getValue().add(testData1);
itemsOut.getValue().add(testData2);

return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + queueMessageId).build();
} else {
return request.createResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Did not find expected items in CosmosDB input list").build();
}
}

@FunctionName("QueueTriggerAndOutputPOJO")
public void queuetriggerandoutputPOJO(
@QueueTrigger(name = "message", queueName = "test-input-java-pojo", connection = "AzureWebJobsStorage") TestData message,
Expand Down
1 change: 0 additions & 1 deletion version.txt

This file was deleted.

0 comments on commit 5786b8b

Please sign in to comment.