-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4b0e05
commit 30678bc
Showing
12 changed files
with
98 additions
and
271 deletions.
There are no files selected for viewing
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
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
9 changes: 5 additions & 4 deletions
9
src/test/java/com/kafkastream/KafkaStreamApplicationTests.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
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
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 |
---|---|---|
@@ -1,66 +1,52 @@ | ||
package com.kafkastream.jersey; | ||
|
||
import lombok.Data; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("calculator") | ||
public class Calculator { | ||
@GET | ||
@Path("squareRoot") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Result squareRoot(@QueryParam("input") double input){ | ||
Result result = new Result("Square Root"); | ||
result.setInput(input); | ||
result.setOutput(Math.sqrt(result.getInput())); | ||
return result; | ||
} | ||
|
||
@GET | ||
@Path("square") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Result square(@QueryParam("input") double input){ | ||
Result result = new Result("Square"); | ||
result.setInput(input); | ||
result.setOutput(result.getInput()*result.getInput()); | ||
return result; | ||
} | ||
|
||
static class Result{ | ||
double input; | ||
double output; | ||
String action; | ||
|
||
public Result(){} | ||
|
||
public Result(String action) { | ||
this.action = action; | ||
} | ||
|
||
public String getAction() { | ||
return action; | ||
} | ||
|
||
public void setAction(String action) { | ||
this.action = action; | ||
} | ||
|
||
public double getInput() { | ||
return input; | ||
} | ||
|
||
public void setInput(double input) { | ||
this.input = input; | ||
} | ||
|
||
public double getOutput() { | ||
return output; | ||
} | ||
|
||
public void setOutput(double output) { | ||
this.output = output; | ||
} | ||
} | ||
public class Calculator | ||
{ | ||
@GET | ||
@Path("squareRoot") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Result squareRoot(@QueryParam("input") double input) | ||
{ | ||
Result result = new Result("Square Root"); | ||
result.setInput(input); | ||
result.setOutput(Math.sqrt(result.getInput())); | ||
return result; | ||
} | ||
|
||
@GET | ||
@Path("square") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Result square(@QueryParam("input") double input) | ||
{ | ||
Result result = new Result("Square"); | ||
result.setInput(input); | ||
result.setOutput(result.getInput() * result.getInput()); | ||
return result; | ||
} | ||
|
||
@Data | ||
static class Result | ||
{ | ||
double input; | ||
double output; | ||
String action; | ||
|
||
public Result() | ||
{ | ||
} | ||
|
||
public Result(String action) | ||
{ | ||
this.action = action; | ||
} | ||
} | ||
} |
Oops, something went wrong.