Skip to content

Instantly share code, notes, and snippets.

View r-winkler's full-sized avatar
🎯
Focusing

René Winkler r-winkler

🎯
Focusing
  • Bern, Switzerland
View GitHub Profile
var arr = [
{ name: "A", value: 10 },
{ name: "B", value: 20 },
{ name: "C", value: 30 },
{ name: "A", value: 40 },
{ name: "B", value: 50 },
{ name: "C", value: 60 }];
var accumulated = arr.reduce(function(accumulator, element) {
var currentValue = accumulator[element.name];
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
npm install webpack --save-dev
npm install webpack -g
npm install babel-loader babel-core --save-dev
npm install babel-cli babel-preset-es2015 --save-dev
module.exports = {
entry: './js/app.js',
output: {
path: './build',
filename: 'bundle.js'
},
module: {
loaders: [
{
...
{
test: /\.css$/,
exclude: /node_modules/,
loader: 'style-loader!css-loader'
},
{
test: /\.scss$/,
exclude: /node_modules/,
loader: 'style-loader!css-loader!saas-loader'
public double totalAmount(List<Items> items) {
double total = 0.0;
for (item : items) {
if (item.getCategory() == "DISCOUNT") {
total += 0.95 * item.getPrice();
}
else if (item.getCategory() == "WEIGHT") {
total += item.getQuantity()*5/1000);
}
else if (item.getCategory() =="SPECIAL") {
public double totalAmount(List<Items> items) {
double total = 0.0;
for (item : items) {
total += item.getPrice();
}
return total;
}
@Test(expected = IllegalArgumentException.class)
public void exceptionTesting() {
try {
throw new IllegalArgumentException("id must not be null");
}
catch(IllegalArgumentException iae) {
assertEquals("id must not be null", iae.getMessage());
throw iae;
}
}
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void shouldThrowExpectedException(){
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("id must not be null");
throw new IllegalArgumentException("id must not be null");
}