Skip to content

Commit 7d1f566

Browse files
committed
feat(tiered-pricing): [outside-in] move fake to use case
1 parent 7db888f commit 7d1f566

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package tv.codely.checkout;
2+
3+
public class CalculateSubscriptionsPrice {
4+
public int execute(String subscriptions) {
5+
return 199;
6+
}
7+
}

exercises/tiered_pricing/solutions/codely_outside-in/src/main/java/tv/codely/checkout/api/Controller/SubscriptionTotalGetController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.springframework.web.bind.annotation.GetMapping;
77
import org.springframework.web.bind.annotation.RequestParam;
88
import org.springframework.web.bind.annotation.RestController;
9+
import tv.codely.checkout.CalculateSubscriptionsPrice;
910

1011
import javax.servlet.http.HttpServletResponse;
1112

@@ -16,6 +17,10 @@ public class SubscriptionTotalGetController {
1617
public ResponseEntity<String> response(@RequestParam String subscriptions, HttpServletResponse response) throws JSONException {
1718
response.addHeader("content-type", "application/json");
1819

19-
return ResponseEntity.ok(new JSONObject().put("total", 199).toString());
20+
var calculateSubscriptionsPrice = new CalculateSubscriptionsPrice();
21+
22+
int total = calculateSubscriptionsPrice.execute(subscriptions);
23+
24+
return ResponseEntity.ok(new JSONObject().put("total", total).toString());
2025
}
2126
}

0 commit comments

Comments
 (0)