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
0 parents
commit 20d3ea9
Showing
191 changed files
with
15,541 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
*.class |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
!SESSION 2011-11-14 11:24:39.615 ----------------------------------------------- | ||
eclipse.buildId=I20110613-1736 | ||
java.version=1.6.0_24 | ||
java.vendor=Apple Inc. | ||
BootLoader constants: OS=macosx, ARCH=x86, WS=cocoa, NL=en_US | ||
Framework arguments: -product org.eclipse.epp.package.jee.product -product org.eclipse.epp.package.jee.product -keyring /Users/mauricioaniche/.eclipse_keyring -showlocation | ||
Command-line arguments: -os macosx -ws cocoa -arch x86 -product org.eclipse.epp.package.jee.product -data /Users/mauricioaniche/dev/workspace-tdd -product org.eclipse.epp.package.jee.product -keyring /Users/mauricioaniche/.eclipse_keyring -showlocation | ||
|
||
!ENTRY org.eclipse.core.net 1 0 2011-11-14 11:24:46.272 | ||
!MESSAGE System property http.nonProxyHosts has been set to local|*.local|169.254/16|*.169.254/16 by an external source. This value will be overwritten using the values from the preferences | ||
|
||
!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2011-11-14 11:24:46.458 | ||
!MESSAGE Could not load repository template extension contributed by com.industriallogic.embunit.eclipse with connectorKind trac | ||
|
||
!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2011-11-14 11:24:46.459 | ||
!MESSAGE Could not load repository template extension contributed by com.industriallogic.gtest.eclipse with connectorKind trac |
Binary file not shown.
Empty file.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
|
10 changes: 10 additions & 0 deletions
10
.metadata/.plugins/org.eclipse.core.resources/.history/0/b0b0dde7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import java.util.List; | ||
|
||
public class ClosingIndicator{ | ||
|
||
public double calculate(int position, List<Candle> serie){ | ||
return serie.get(position).getClosing(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
.metadata/.plugins/org.eclipse.core.resources/.history/11/0092d9e7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import java.util.Calendar; | ||
|
||
public class Candle { | ||
|
||
private double opening; | ||
private double closing; | ||
private double minimum; | ||
private double maximum; | ||
private Calendar date; | ||
|
||
public Candle(double opening, double closing, double minimum, | ||
double maximum, Calendar date) { | ||
this.opening = opening; | ||
this.closing = closing; | ||
this.minimum = minimum; | ||
this.maximum = maximum; | ||
this.date = date; | ||
} | ||
|
||
public double getOpening() { | ||
return opening; | ||
} | ||
public double getClosing() { | ||
return closing; | ||
} | ||
public double getMinimum() { | ||
return minimum; | ||
} | ||
public double getMaximum() { | ||
return maximum; | ||
} | ||
public Calendar getDate() { | ||
return date; | ||
} | ||
|
||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
.metadata/.plugins/org.eclipse.core.resources/.history/16/c06dc5e7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
|
||
import org.junit.Test; | ||
|
||
public class MinimumIndicatorTests { | ||
|
||
@Test | ||
public void shouldReturnTheMinimumCandleValue() { | ||
double amount = new MinimumIndicator().calculate(1, Arrays.asList( | ||
candleWithMinimum(10.0), candleWithMinimum(12.0), | ||
candleWithMinimum(11.0))); | ||
|
||
assertEquals(12.0, amount, 0.00001); | ||
|
||
} | ||
|
||
private Candle candleWithMinimum(double minimum) { | ||
return new Candle(0, 0, minimum, 0, Calendar.getInstance()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.metadata/.plugins/org.eclipse.core.resources/.history/22/80020decc40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.caelum.tdd.exercise6.Candle; | ||
import br.com.caelum.tdd.exercise6.MinimumIndicator; | ||
|
||
public class MinimumIndicatorTests { | ||
|
||
@Test | ||
public void shouldReturnTheMinimumCandleValue() { | ||
double amount = new MinimumIndicator().calculate(1, Arrays.asList( | ||
candleWithMinimum(10.0), candleWithMinimum(12.0), | ||
candleWithMinimum(11.0))); | ||
|
||
assertEquals(12.0, amount, 0.00001); | ||
|
||
} | ||
|
||
private Candle candleWithMinimum(double minimum) { | ||
return new Candle(0, 0, minimum, 0, Calendar.getInstance()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.metadata/.plugins/org.eclipse.core.resources/.history/3a/d08ddbe7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import java.util.List; | ||
|
||
public class WeightedMovingAverage{ | ||
|
||
public double calculate(int position, List<Candle> series, String type){ | ||
double sum = 0.0; | ||
int weight = 1; | ||
|
||
for(int i = position -2; i <= position; i++){ | ||
Candle c = series.get(i); | ||
sum += (type.equals("opening")? c.getOpening() : c.getClosing())*weight; | ||
weight++; | ||
} | ||
return sum/6; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.metadata/.plugins/org.eclipse.core.resources/.history/3e/b0ced8e7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import java.util.List; | ||
|
||
public class MaximumIndicator{ | ||
|
||
public double calculate(int position, List<Candle> serie){ | ||
return serie.get(position).getMaximum(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
.metadata/.plugins/org.eclipse.core.resources/.history/4f/90f8c4e7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
|
||
import org.junit.Test; | ||
|
||
public class MaximumIndicatorTests { | ||
|
||
@Test | ||
public void shouldReturnTheMaximumCandleValue() { | ||
double amount = new MaximumIndicator().calculate(1, Arrays.asList( | ||
candleWithMaximum(10.0), candleWithMaximum(12.0), | ||
candleWithMaximum(11.0))); | ||
|
||
assertEquals(12.0, amount, 0.00001); | ||
|
||
} | ||
|
||
private Candle candleWithMaximum(double maximum) { | ||
return new Candle(0, 0, 0, maximum, Calendar.getInstance()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.metadata/.plugins/org.eclipse.core.resources/.history/51/b0060becc40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.caelum.tdd.exercise6.Candle; | ||
import br.com.caelum.tdd.exercise6.OpeningIndicator; | ||
|
||
public class OpeningIndicatorTests { | ||
|
||
@Test | ||
public void shouldReturnCandleOpeningValue() { | ||
double amount = new OpeningIndicator().calculate(1, Arrays.asList( | ||
candleWithOpening(10.0), candleWithOpening(12.0), | ||
candleWithOpening(11.0))); | ||
|
||
assertEquals(12.0, amount, 0.00001); | ||
|
||
} | ||
|
||
private Candle candleWithOpening(double opening) { | ||
return new Candle(opening, 0, 0, 0, Calendar.getInstance()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.metadata/.plugins/org.eclipse.core.resources/.history/6f/2051dce7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import java.util.List; | ||
|
||
public class MinimumIndicator{ | ||
|
||
public double calculate(int position, List<Candle> serie){ | ||
return serie.get(position).getMinimum(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.metadata/.plugins/org.eclipse.core.resources/.history/75/e0ec0decc40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.caelum.tdd.exercise6.Candle; | ||
import br.com.caelum.tdd.exercise6.ClosingIndicator; | ||
|
||
public class ClosingIndicatorTests { | ||
|
||
@Test | ||
public void shouldReturnClosingCandleValue() { | ||
double amount = new ClosingIndicator().calculate(1, Arrays.asList( | ||
candleWithClosing(10.0), candleWithClosing(12.0), | ||
candleWithClosing(11.0))); | ||
|
||
assertEquals(12.0, amount, 0.00001); | ||
|
||
} | ||
|
||
private Candle candleWithClosing(double closing) { | ||
return new Candle(0, closing, 0, 0, Calendar.getInstance()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
.metadata/.plugins/org.eclipse.core.resources/.history/7f/60121cd9c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package br.com.gnarus.tdd.exercise5; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.gnarus.tdd.exercise5.RegularBankAccount; | ||
|
||
public class RegularBankAccountTests { | ||
|
||
@Test | ||
public void shouldDepositAmount() { | ||
RegularBankAccount account = new RegularBankAccount(); | ||
|
||
account.deposit(1000.0); | ||
assertEquals(1000, account.getBalance(), 0.00001); | ||
|
||
account.deposit(500.5); | ||
assertEquals(1500.5, account.getBalance(), 0.00001); | ||
} | ||
|
||
|
||
public void shouldWithDrawIfAmountIsLessThanTheAvailableBalance() { | ||
RegularBankAccount account = new RegularBankAccount(); | ||
account.deposit(1000.0); | ||
|
||
account.withdraw(900); | ||
|
||
assertEquals(100.0, account.getBalance(), 0.00001); | ||
} | ||
|
||
@Test(expected=IllegalArgumentException.class) | ||
public void shouldForbitWithdrawIfRequestedAmountIsGreaterThanCurrentBalance() { | ||
RegularBankAccount account = new RegularBankAccount(); | ||
account.deposit(1000.0); | ||
|
||
account.withdraw(2000.0); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
.metadata/.plugins/org.eclipse.core.resources/.history/7f/60eddce7c40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import java.util.List; | ||
|
||
public class OpeningIndicator{ | ||
|
||
public double calculate(int position, List<Candle> serie){ | ||
return serie.get(position).getOpening(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.metadata/.plugins/org.eclipse.core.resources/.history/8e/60430aecc40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package br.com.caelum.tdd.exercicio6; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.caelum.tdd.exercise6.Candle; | ||
import br.com.caelum.tdd.exercise6.MaximumIndicator; | ||
|
||
public class MaximumIndicatorTests { | ||
|
||
@Test | ||
public void shouldReturnTheMaximumCandleValue() { | ||
double amount = new MaximumIndicator().calculate(1, Arrays.asList( | ||
candleWithMaximum(10.0), candleWithMaximum(12.0), | ||
candleWithMaximum(11.0))); | ||
|
||
assertEquals(12.0, amount, 0.00001); | ||
|
||
} | ||
|
||
private Candle candleWithMaximum(double maximum) { | ||
return new Candle(0, 0, 0, maximum, Calendar.getInstance()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.metadata/.plugins/org.eclipse.core.resources/.history/91/8018396ec40e00111a58c5914cb3b3bc
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package br.com.caelum.tdd.exercise3; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.caelum.tdd.exercise3.Bankslip; | ||
import br.com.caelum.tdd.exercise3.BankslipProcessor; | ||
import br.com.caelum.tdd.exercise3.Invoice; | ||
import br.com.caelum.tdd.exercise3.Payment; | ||
import br.com.caelum.tdd.exercise3.PaymentMethod; | ||
|
||
public class BankslipProcessorTest { | ||
|
||
@Test | ||
public void shouldNotGeneratePaymentWhenThereIsNoBankslips() { | ||
Invoice invoice = new Invoice("caelum", 1000.0); | ||
List<Bankslip> paidBankslips = Collections.emptyList(); | ||
|
||
new BankslipProcessor().process(paidBankslips, invoice); | ||
|
||
assertEquals(0, invoice.getPayments().size()); | ||
} | ||
|
||
@Test | ||
public void shouldGenerateABankslipPaymentForAnInvoice() { | ||
Invoice invoice = new Invoice("caelum", 1000.0); | ||
List<Bankslip> paidBankslips = Arrays.asList(new Bankslip(200.0), new Bankslip(500.0)); | ||
|
||
new BankslipProcessor().process(paidBankslips, invoice); | ||
|
||
assertEquals(2, invoice.getPayments().size()); | ||
assertEquals(new Payment(200.0, PaymentMethod.BANKSLIP), invoice.getPayments().get(0)); | ||
assertEquals(new Payment(500.0, PaymentMethod.BANKSLIP), invoice.getPayments().get(1)); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.