This file contains hidden or 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
package code.puzzles; | |
public class WebserviceHelper { | |
private final Webservice webservice = new Webservice(); | |
public Products getProducts(final Integer category, final Integer quantity) throws WebserviceException{ | |
Products products; | |
try { | |
products = webservice.getProducts(category, quantity); | |
} catch(RuntimeException e) { | |
throw new WebserviceException("failed invoking the webservice with category "+category+" and quantity "+quantity, e); |
This file contains hidden or 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
//webservicehelper with closures and generics | |
package code.puzzles; | |
public class WebserviceHelper { | |
private final Webservice webservice = new Webservice(); | |
public Products getProducts(final Integer category, final Integer quantity) throws WebserviceException{ | |
WebserviceInvoker<Products> invoker = new WebserviceInvoker<Products>() { | |
public Products invoke() { | |
return webservice.getProducts(category, quantity); | |
} |
This file contains hidden or 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
public class BillFormatter { | |
public String format(int price, Currency currency) throws UnknownCurrencyException { | |
String formattedPrice = "Your total is : "; | |
if (currency == Currency.EUROS) { | |
formattedPrice += price + "€"; | |
} else if (currency == Currency.POUNDS) { | |
formattedPrice += "£" + price; | |
} else { | |
throw new UnknownCurrencyException(); |
This file contains hidden or 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
package code.puzzles; | |
import code.puzzles.TheRestOfTheCode.Products; | |
import code.puzzles.TheRestOfTheCode.Rebates; | |
import code.puzzles.TheRestOfTheCode.Webservice; | |
import code.puzzles.TheRestOfTheCode.WebserviceException; | |
public class WebserviceHelper { | |
private Webservice webservice; | |
public Products getProductsByCategoryAndQuantity(final Integer category, final Integer quantity) throws WebserviceException{ |
This file contains hidden or 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
<?php | |
class ActionTest extends PHPUnit_Framework_TestCase { | |
protected $action; | |
public function setUp() { | |
$debug = true; | |
$configuration = ProjectConfiguration:: | |
getApplicationConfiguration('frontend', 'test', $debug); | |
$sfContext = sfContext::createInstance($configuration); |
This file contains hidden or 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
public class BatchCrawler { | |
public BatchCrawler(Job job) { | |
this.job = job; | |
this.timeout = ConfigurationService.getInt(SCAN_TIMEOUT); | |
httpCrawler = new RetryingHttpCrawler(); | |
} | |
public CrawlResult crawl() { | |
CrawlResult crawlResult = new CrawlResult(); |
This file contains hidden or 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
(ns medics | |
(:use [clojure-tdd.core] :reload) | |
(:use [clojure.test]) | |
(:use [midje.sweet])) | |
(unfinished box-size) | |
(defn ciel-quot [num div] | |
(inc (quot (dec num) div))) |
This file contains hidden or 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
(def number) | |
(defn- for-all [fbq-digits text] | |
(let [extra-fbqs (for [d (str number) :when (fbq-digits d)] (fbq-digits d))] | |
(concat text extra-fbqs))) | |
(defn if-divisible-by [[div suffix] text] | |
(if (zero? (rem number div)) | |
(conj text suffix) | |
text)) |
This file contains hidden or 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
import static org.hamcrest.Matchers.contains; | |
import static org.junit.Assert.assertThat; | |
import static org.mockito.Mockito.verify; | |
import static org.mockito.Mockito.verifyNoMoreInteractions; | |
import static org.mockito.Mockito.when; | |
import java.util.Arrays; | |
import java.util.List; | |
import org.junit.Test; |
This file contains hidden or 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
(ns lean-challenge.core | |
(:use [midje.sweet])) | |
; ==== application core | |
(defn cost [fruit] | |
({"b" 150 "a" 100 "p" 100 "m" 100 "c" 75} fruit)) | |
(defn csv-to-col [s] | |
(seq (.split s ","))) |
OlderNewer