Skip to content

Commit

Permalink
Revert "update source according to the change of new runtime (#29)" (#39
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jdneo authored Jul 23, 2018
1 parent 6cb3dc7 commit 4155d84
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<azure.functions.maven.plugin.version>1.0.0-beta-3</azure.functions.maven.plugin.version>
<azure.functions.java.library.version>1.0.0-beta-5</azure.functions.java.library.version>
<azure.functions.java.library.version>1.0.0-beta-4</azure.functions.java.library.version>
<functionAppName>${appName}</functionAppName>
<functionAppRegion>${appRegion}</functionAppRegion>
<stagingDirectory>${project.build.directory}/azure-functions/${functionAppName}</stagingDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class Function {
* 2. curl {your host}/api/HttpTrigger-Java?name=HTTP%20Query
*/
@FunctionName("HttpTrigger-Java")
public HttpResponseMessage HttpTriggerJava(
@HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
public HttpResponseMessage<String> HttpTriggerJava(
@HttpTrigger(name = "req", methods = {"get", "post"}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request.");

Expand All @@ -24,9 +24,9 @@ public HttpResponseMessage HttpTriggerJava(
String name = request.getBody().orElse(query);

if (name == null) {
return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build();
return request.createResponse(400, "Please pass a name on the query string or in the request body");
} else {
return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
return request.createResponse(200, "Hello, " + name);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package $package;

import org.junit.Test;

import com.microsoft.azure.functions.*;

import java.util.HashMap;
Expand All @@ -10,7 +9,7 @@
import java.util.logging.Logger;

import static org.junit.Assert.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
Expand All @@ -24,7 +23,7 @@ public class FunctionTest {
* Unit test for HttpTriggerJava method.
*/
@Test
public void testHttpTriggerJava() throws Exception {
public void testHello() throws Exception {
// Setup
final HttpRequestMessage<Optional<String>> req = mock(HttpRequestMessage.class);

Expand All @@ -35,13 +34,8 @@ public void testHttpTriggerJava() throws Exception {
final Optional<String> queryBody = Optional.empty();
doReturn(queryBody).when(req).getBody();


final HttpResponseMessage.Builder builder = mock(HttpResponseMessage.Builder.class);
doReturn(builder).when(req).createResponseBuilder(any(HttpStatus.class));
doReturn(builder).when(builder).body(anyString());

final HttpResponseMessage res = mock(HttpResponseMessage.class);
doReturn(res).when(builder).build();
doReturn(res).when(req).createResponse(anyInt(), anyString());

final ExecutionContext context = mock(ExecutionContext.class);
doReturn(Logger.getGlobal()).when(context).getLogger();
Expand Down

0 comments on commit 4155d84

Please sign in to comment.