Shipping agent provides origin, destination and arrival deadline. Origin and destination as UN locode [1].
System assigns a unique tracking id. Tracking id should be unique and generated by the system.
Cargo is initially unrouted.
function renderJsonp(res, callback) { | |
res.append('Content-Type', 'application/javascript'); | |
res.send(callback + '(' + JSON.stringify(res.body) + ');'); | |
} | |
function renderJson(res) { | |
res.send(res.body); | |
} | |
function render(req, res) { |
import com.github.benmanes.caffeine.cache.CacheLoader | |
import com.github.benmanes.caffeine.cache.Caffeine | |
import com.github.benmanes.caffeine.cache.Ticker | |
import org.assertj.core.api.Assertions.assertThat | |
import org.junit.Test | |
import java.util.concurrent.TimeUnit | |
import java.util.concurrent.atomic.AtomicInteger | |
class CaffeineAsyncRefreshableCacheTest { | |
@Test |
import arrow.fx.IO | |
import arrow.fx.extensions.io.concurrent.concurrent | |
import arrow.fx.extensions.io.concurrent.dispatchers | |
import arrow.fx.fix | |
import kotlin.test.Test | |
fun f1(): IO<String> = IO { | |
"f1 ${Thread.currentThread().name}" | |
} |
Invoice invoice; | |
@BeforeEach | |
void setup() { | |
createInvoiceToSave(); | |
} | |
@Test | |
void standardInvoice() { | |
mockCustomerFinder(); |
int id = 12345; | |
BigDecimal amount = new BigDecimal(100); | |
Customer customer = new Customer(null, null); | |
@Test | |
void standardInvoice() { | |
when(authenticatedCustomerFinder.apply()).thenReturn(customer); | |
createInvoiceUseCase.create(id, amount); | |
class MeteredCacheTest { | |
Meter gets = new Meter(); | |
Meter puts = new Meter(); | |
Meter hits = new Meter(); | |
MetricRegistry metrics = new MetricRegistry(); | |
Cache delegate = mock<Cache>(); | |
Cache cache = new MeteredCache(delegate, metrics); | |
@Test |
def total(croissants: Pricing, baguettes: Pricing, breadRolls: Pricing): BigDecimal = { | |
val initialTotal = BigDecimal(0) | |
val croissantsTotal = initialTotal + total(croissants) | |
val baguettesTotal = croissantsTotal + total(baguettes) | |
baguettesTotal + total(breadRolls) | |
} |
def total(pricings: List[Pricing]): BigDecimal = | |
pricings.foldLeft(BigDecimal(0)) { (grandTotal, pricing) => | |
grandTotal + total(pricing) | |
} |
private def total(quantity: Int, tierPrice: TierPrice, unitPrice: UnitPrice): BigDecimal = { | |
// initial value | |
var total = BigDecimal(0) | |
// iteration 1 - tier price | |
val tiers = quantity / tierPrice.quantity | |
val tierPriceAmount = tiers * tierPrice.price | |
// accumulator to pass to the iteration 2 | |
val remainingQuantityAfterTierPrice = quantity % tierPrice.quantity | |
total = total + tierPriceAmount |