JavaForFun
7 years agoFixing coverage in Clock.today()
Gustavo Martin Morcuende [Sun, 4 Dec 2016 22:09:17 +0000 (23:09 +0100)]
Fixing coverage in Clock.today()

My implementation solves the coverage issue (hopefully it is right)

7 years agoHow to configure IDE Eclipse
Gustavo Martin Morcuende [Sun, 4 Dec 2016 20:36:27 +0000 (21:36 +0100)]
How to configure IDE Eclipse

7 years agoWe end up writing our application based on the acceptance test
Gustavo Martin Morcuende [Sun, 4 Dec 2016 20:35:31 +0000 (21:35 +0100)]
We end up writing our application based on the acceptance test

7 years agoPrintStatementeFeature requires the right values for clock.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 20:30:50 +0000 (21:30 +0100)]
PrintStatementeFeature requires the right values for clock.

7 years agoBIG WARNING: Clock.today() is not under test!!!!
Gustavo Martin Morcuende [Sun, 4 Dec 2016 20:21:43 +0000 (21:21 +0100)]
BIG WARNING: Clock.today() is not under test!!!!

Our tests do not fail even if we return null from there...

7 years agoMaking StatementPrinter and StatementPrinterShould look better
Gustavo Martin Morcuende [Sun, 4 Dec 2016 20:11:59 +0000 (21:11 +0100)]
Making StatementPrinter and StatementPrinterShould look better

7 years agoStatementPrinter, test for print method green
Gustavo Martin Morcuende [Sun, 4 Dec 2016 20:09:46 +0000 (21:09 +0100)]
StatementPrinter, test for print method green

7 years agoStatementPrinterShould is failing for the right reasons.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 19:02:02 +0000 (20:02 +0100)]
StatementPrinterShould is failing for the right reasons.

7 years agoThe acceptance test is failing because we need to implement the print method in State...
Gustavo Martin Morcuende [Sun, 4 Dec 2016 18:49:14 +0000 (19:49 +0100)]
The acceptance test is failing because we need to implement the print method in StatementPrinter.

We always write first a test and then the implementation.
In this case we have to create the test called StatementPrinterShould and from
there we can create the implementation for the print method.

7 years agoClock test is green.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 18:32:51 +0000 (19:32 +0100)]
Clock test is green.

Inline as much code as possible (getting ride of variables)
We isolate and control the randomness in our code.
No using spies, instead, we use private classes in our tests.

7 years agoClock test working but we need to control the random part.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 17:47:15 +0000 (18:47 +0100)]
Clock test working but we need to control the random part.

We need it in order to write tests that will work in any day.

7 years agoRenaming local variables in TransactionRepository
Gustavo Martin Morcuende [Sun, 4 Dec 2016 17:36:34 +0000 (18:36 +0100)]
Renaming local variables in TransactionRepository

7 years agoRemoving duplications from TransactionRepositoryShould
Gustavo Martin Morcuende [Sun, 4 Dec 2016 17:35:51 +0000 (18:35 +0100)]
Removing duplications from TransactionRepositoryShould

7 years agoNow we have a test for addWithdrawal
Gustavo Martin Morcuende [Sun, 4 Dec 2016 17:34:45 +0000 (18:34 +0100)]
Now we have a test for addWithdrawal

7 years agoIt is only left a test for addWithdrawal
Gustavo Martin Morcuende [Sun, 4 Dec 2016 17:31:12 +0000 (18:31 +0100)]
It is only left a test for addWithdrawal

7 years agoTests failing for the right reason
Gustavo Martin Morcuende [Sun, 4 Dec 2016 17:25:48 +0000 (18:25 +0100)]
Tests failing for the right reason

We need to keep implementing methods.

7 years agoTests are failing for the right reasons
Gustavo Martin Morcuende [Sun, 4 Dec 2016 17:13:27 +0000 (18:13 +0100)]
Tests are failing for the right reasons

They throw UnsupportedOperationException because we need the implementations.

7 years agoWe have a green test for AccountShould
Gustavo Martin Morcuende [Sun, 4 Dec 2016 16:41:58 +0000 (17:41 +0100)]
We have a green test for AccountShould

But PrintStatementFeature is failing because the acceptance test is using
the real classes, it tells me what has not been implemented :)

7 years agoAccountShould is failing for the right reasons.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 16:33:11 +0000 (17:33 +0100)]
AccountShould is failing for the right reasons.

We can now implement the printStatement method.

7 years agoWe have to test the printStatement method in Account
Gustavo Martin Morcuende [Sun, 4 Dec 2016 16:21:38 +0000 (17:21 +0100)]
We have to test the printStatement method in Account

7 years agoDelegating the responsability of storing transactions.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 16:16:15 +0000 (17:16 +0100)]
Delegating the responsability of storing transactions.

TransactionRepository will store transactions.

7 years agoCreating test for Account.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 15:57:30 +0000 (16:57 +0100)]
Creating test for Account.

Always write first your asserts.

7 years agoNow we have test expecting some result, it is now failing for the right reasons.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 15:19:08 +0000 (16:19 +0100)]
Now we have test expecting some result, it is now failing for the right reasons.

We are using the double loop of unit testing:

* First, start with an acceptance test.
* Second, once the acceptance test is failing for the right reason then you
go to the inner loop of TDD (the unit test) we can start unit testing our code.
  Once we have all the classes under unit tests our accpetance test should go green.

7 years agoTest throws UnsupportedOperationException as expected.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 15:18:39 +0000 (16:18 +0100)]
Test throws UnsupportedOperationException as expected.

You should configure your IDE for throwing UnsupportedOperationException
whenever it automatically creates a method. In this way, when running
our unit tests we are able to find out what is not yet implemented.

7 years agoWe finish writing our test.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 15:03:32 +0000 (16:03 +0100)]
We finish writing our test.

7 years agoWriting the asserts and the trigger for those asserts.
Gustavo Martin Morcuende [Sun, 4 Dec 2016 14:59:05 +0000 (15:59 +0100)]
Writing the asserts and the trigger for those asserts.

7 years agoFirst acceptance test
Gustavo Martin Morcuende [Sun, 4 Dec 2016 14:46:11 +0000 (15:46 +0100)]
First acceptance test

Use interfaces for representing the external world.

7 years agoAcceptance test, README (constraints)
Gustavo Martin Morcuende [Sun, 4 Dec 2016 14:18:13 +0000 (15:18 +0100)]
Acceptance test, README (constraints)

7 years agoRxJava: using flatMap method
Gustavo Martin Morcuende [Fri, 2 Dec 2016 22:44:05 +0000 (23:44 +0100)]
RxJava: using flatMap method

7 years agoDealing with InterruptedException, the right way.
Gustavo Martin Morcuende [Fri, 2 Dec 2016 22:20:14 +0000 (23:20 +0100)]
Dealing with InterruptedException, the right way.

7 years agoClosing fd as it must be done in CustomHTTPClient
Gustavo Martin Morcuende [Fri, 2 Dec 2016 21:18:03 +0000 (22:18 +0100)]
Closing fd as it must be done in CustomHTTPClient

I feel ashame... :(

7 years agoMerge branch 'master' of https://github.com/gumartinm/JavaForFun
Gustavo Martin Morcuende [Fri, 2 Dec 2016 21:00:36 +0000 (22:00 +0100)]
Merge branch 'master' of https://github.com/gumartinm/JavaForFun

7 years agoHaving fun with RxJava
Gustavo Martin Morcuende [Fri, 2 Dec 2016 20:58:55 +0000 (21:58 +0100)]
Having fun with RxJava

8 years agoOutside in TDD
Gustavo Martin Morcuende [Sun, 27 Nov 2016 17:43:42 +0000 (18:43 +0100)]
Outside in TDD

https://www.youtube.com/watch?v=XHnuMjah6ps

8 years agoWe will add our exceptions to the enum.
Gustavo Martin Morcuende [Sun, 27 Nov 2016 17:36:51 +0000 (18:36 +0100)]
We will add our exceptions to the enum.

8 years agoTesting IV
Gustavo Martin Morcuende [Sun, 27 Nov 2016 17:27:34 +0000 (18:27 +0100)]
Testing IV

We are in position of testing exceptions like IV.
Exceptions will be added to enum and our algorithm we will keep working.

8 years agoRemoving duplicated loop.
Gustavo Martin Morcuende [Sun, 27 Nov 2016 17:19:23 +0000 (18:19 +0100)]
Removing duplicated loop.

Two loops were doing the same (appending letters)

8 years agoWriting test for XXX requires a while loop
Gustavo Martin Morcuende [Sun, 27 Nov 2016 17:16:02 +0000 (18:16 +0100)]
Writing test for XXX requires a while loop

Duplication: there is two loops appending letters, we want to remove one because
both of them are doing the same.

8 years agoRemoving duplications.
Gustavo Martin Morcuende [Sun, 27 Nov 2016 17:10:18 +0000 (18:10 +0100)]
Removing duplications.

We need to map X and V to numbers. We achive it by means of an enum.

8 years agoWriting test for XVIII
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:56:00 +0000 (17:56 +0100)]
Writing test for XVIII

We see duplications again :)

8 years agoWriting test for X
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:52:15 +0000 (17:52 +0100)]
Writing test for X

8 years agoWriting test for VII
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:49:42 +0000 (17:49 +0100)]
Writing test for VII

8 years agoTesting another simple case, V
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:46:06 +0000 (17:46 +0100)]
Testing another simple case, V

We skip IV because it is an exception.

8 years agotripservice: link to youtube tutorial
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:44:34 +0000 (17:44 +0100)]
tripservice: link to youtube tutorial

8 years agoGeneralize code.
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:35:11 +0000 (17:35 +0100)]
Generalize code.

From duplications we identify pattern and generalize our code.

8 years agoAgain we write the simplest thing to make our test green
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:30:33 +0000 (17:30 +0100)]
Again we write the simplest thing to make our test green

And we see duplications :)

8 years agoWe always write the simplest thing to make our test green
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:25:09 +0000 (17:25 +0100)]
We always write the simplest thing to make our test green

8 years agoRomanNumeralGenerator, first test passing
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:18:57 +0000 (17:18 +0100)]
RomanNumeralGenerator, first test passing

8 years agoRomanNumeralGenerator, creating test (first) and class (second)
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:15:56 +0000 (17:15 +0100)]
RomanNumeralGenerator, creating test (first) and class (second)

8 years agoromannumerals
Gustavo Martin Morcuende [Sun, 27 Nov 2016 16:03:59 +0000 (17:03 +0100)]
romannumerals

8 years agodifferent projects for codurance
Gustavo Martin Morcuende [Sun, 27 Nov 2016 15:52:24 +0000 (16:52 +0100)]
different projects for codurance

8 years agonew projects, tdd and sandomancuso
Gustavo Martin Morcuende [Sun, 27 Nov 2016 15:27:04 +0000 (16:27 +0100)]
new projects, tdd and sandomancuso

8 years agoREADME file
Gustavo Martin Morcuende [Sun, 27 Nov 2016 14:17:07 +0000 (15:17 +0100)]
README file

8 years agoTripService we can refactor as much as we want because everything is under test.
Gustavo Martin Morcuende [Sun, 27 Nov 2016 14:10:52 +0000 (15:10 +0100)]
TripService we can refactor as much as we want because everything is under test.

Creating validate method.

8 years agoRequired dependency for @Inject
Gustavo Martin Morcuende [Sun, 27 Nov 2016 14:08:27 +0000 (15:08 +0100)]
Required dependency for @Inject

8 years agoTripServiceShould green
Gustavo Martin Morcuende [Sun, 27 Nov 2016 14:07:07 +0000 (15:07 +0100)]
TripServiceShould green

TripService is green again, we are using BDDMockito (which integrates nicely with //given //when //then comments)
and we can delete code from our TripServiceShould unit test

8 years agoreturn_friend_trips_when_users_are_friends fails
Gustavo Martin Morcuende [Sun, 27 Nov 2016 13:55:53 +0000 (14:55 +0100)]
return_friend_trips_when_users_are_friends fails

Now test is using my Mock but it keeps failing with a different error :)

8 years agoreturn_friend_trips_when_users_are_friends stops working
Gustavo Martin Morcuende [Sun, 27 Nov 2016 13:46:55 +0000 (14:46 +0100)]
return_friend_trips_when_users_are_friends stops working

When a test fails we have a reason for refactoring our legacy code!!!
In this case the problema is related to using the static method of TripDAO

8 years agoTripDAO, always test before refactoring
Gustavo Martin Morcuende [Sun, 27 Nov 2016 13:26:05 +0000 (14:26 +0100)]
TripDAO, always test before refactoring

We need a new method in order to be able to rewrite our legacy code.
At the very end this method will be the one used by our app.
The static method will dissapear after refactoring our whole app (what should be done carefully)

8 years agoRemoving loggedInUser from Test.
Gustavo Martin Morcuende [Fri, 25 Nov 2016 00:15:11 +0000 (01:15 +0100)]
Removing loggedInUser from Test.

Less variables makes our code more simple.

8 years agoGetting rid of getLoggedInUser() method
Gustavo Martin Morcuende [Fri, 25 Nov 2016 00:10:22 +0000 (01:10 +0100)]
Getting rid of getLoggedInUser() method

8 years agoMVC, Model should know nothing about View.
Gustavo Martin Morcuende [Fri, 25 Nov 2016 00:04:26 +0000 (01:04 +0100)]
MVC, Model should know nothing about View.

Service is in Model layer, it should not be dealing with sessions (View)

8 years agoTripService refactored
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:51:30 +0000 (00:51 +0100)]
TripService refactored

8 years agoGetting rid of variable makes code easier.
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:46:58 +0000 (00:46 +0100)]
Getting rid of variable makes code easier.

There could be performance issues, but if there are not problems this code is better.

8 years agoUsing ternary operation
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:46:10 +0000 (00:46 +0100)]
Using ternary operation

8 years agoGetting rid of variables in legacy code is great.
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:41:11 +0000 (00:41 +0100)]
Getting rid of variables in legacy code is great.

It enables us to reuse methods.
Once we take away as many variables as posible we can remake optimizations.

8 years agoMoving Guard Condition to the top
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:31:02 +0000 (00:31 +0100)]
Moving Guard Condition to the top

8 years agoInline isFriendsWith(user)
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:18:35 +0000 (00:18 +0100)]
Inline isFriendsWith(user)

8 years agoUser isFriendsWith(user) method in TripService
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:15:16 +0000 (00:15 +0100)]
User isFriendsWith(user) method in TripService

8 years agoisFriendsWith(user) method added to User
Gustavo Martin Morcuende [Thu, 24 Nov 2016 23:08:26 +0000 (00:08 +0100)]
isFriendsWith(user) method added to User

8 years agoMoving UserBuilder to production code
Gustavo Martin Morcuende [Thu, 24 Nov 2016 22:49:48 +0000 (23:49 +0100)]
Moving UserBuilder to production code

8 years agoThoughts about Feature Envy and path to follow when refactoring legacy code
Gustavo Martin Morcuende [Thu, 24 Nov 2016 01:12:29 +0000 (02:12 +0100)]
Thoughts about Feature Envy and path to follow when refactoring legacy code

1. When writing tests for legacy code we go from shortest to deepest branches.
2. When refactoring legacy code (handmade modifications) we go from deepest to shortest branches (just the opposite)

Feauture envy: some class (TripService) wants to do some action that should be implemented by another class which we
are using to extract the data and perform some action. Data and action should be done by the same class (User)

8 years agoMerge branch 'master' of https://github.com/gumartinm/JavaForFun
Gustavo Martin Morcuende [Thu, 24 Nov 2016 00:56:56 +0000 (01:56 +0100)]
Merge branch 'master' of https://github.com/gumartinm/JavaForFun

8 years agoImprovement with fluent interface for our test
Gustavo Martin Morcuende [Thu, 24 Nov 2016 00:50:37 +0000 (01:50 +0100)]
Improvement with fluent interface for our test

We now have the legacy code under test. So now and not before we can refactor the legacy code.

8 years agoImprovement with fluent interface for our test
Gustavo Martin Morcuende [Thu, 24 Nov 2016 00:50:37 +0000 (01:50 +0100)]
Improvement with fluent interface for our test

8 years agoRemoving duplicated code
Gustavo Martin Morcuende [Wed, 23 Nov 2016 21:00:00 +0000 (22:00 +0100)]
Removing duplicated code

8 years agoWe must always turn static methods into protected ones.
Gustavo Martin Morcuende [Wed, 23 Nov 2016 20:52:26 +0000 (21:52 +0100)]
We must always turn static methods into protected ones.

It is the only way of testing them (without using PowerMockito and stuff like that)
Remember, every change in the legacy code must be done by the tools proviede by our IDE (Eclipse, InteliJ, etc)
you must never rewrite by hand the legacy code.

8 years agoRemoving duplicated code
Gustavo Martin Morcuende [Wed, 23 Nov 2016 20:31:23 +0000 (21:31 +0100)]
Removing duplicated code

8 years agoWe test the next branch.
Gustavo Martin Morcuende [Sun, 20 Nov 2016 22:44:01 +0000 (23:44 +0100)]
We test the next branch.

Remember: the assert must match the unit test method's name!!
In this case, no trips must be returned.

8 years agoCreating test for refactoring legacy code.
Gustavo Martin Morcuende [Sun, 20 Nov 2016 22:21:45 +0000 (23:21 +0100)]
Creating test for refactoring legacy code.

1. We may not change production code if not covered by tests.
2. Start testing the legacy code following the shortest branch.
3. We should not invoke more classes than the one being under test.
4. We try to create a fluent interface. If we are testing user is not logged in, our test must
set the value making the not logged in user (we will call it GUEST)
5. Making clear that the input parameter in getTripsByUser is useless for the Unit Test throw_an_exception_when_user_is_not_logged_in

8 years agoSandro Mancuso, tripservicekata.
Gustavo Martin Morcuende [Sun, 20 Nov 2016 21:42:43 +0000 (22:42 +0100)]
Sandro Mancuso, tripservicekata.

8 years agospring-jpa, liquibase, examples about how to update change sets in database
Gustavo Martin Morcuende [Wed, 14 Sep 2016 12:57:13 +0000 (14:57 +0200)]
spring-jpa, liquibase, examples about how to update change sets in database

8 years agoSTOMP: log4j2 improvements
Gustavo Martin Morcuende [Sat, 27 Aug 2016 22:02:53 +0000 (00:02 +0200)]
STOMP: log4j2 improvements

8 years agoSpring STOMP simple server: a few improvements
Gustavo Martin Morcuende [Sat, 27 Aug 2016 00:29:58 +0000 (02:29 +0200)]
Spring STOMP simple server: a few improvements

8 years agoSpring JPA: missing Named annotation in a few Spring services
Gustavo Martin Morcuende [Tue, 23 Aug 2016 01:35:04 +0000 (03:35 +0200)]
Spring JPA: missing Named annotation in a few Spring services

8 years agoSonarQube custom plugins, little improvement
Gustavo Martin Morcuende [Tue, 23 Aug 2016 00:47:38 +0000 (02:47 +0200)]
SonarQube custom plugins, little improvement

8 years agoSonarQube custom JavaScript plugin, unit tests
Gustavo Martin Morcuende [Mon, 22 Aug 2016 21:01:02 +0000 (23:01 +0200)]
SonarQube custom JavaScript plugin, unit tests

8 years agoSonarQube custom Java plugin, unit tests
Gustavo Martin Morcuende [Mon, 22 Aug 2016 20:42:59 +0000 (22:42 +0200)]
SonarQube custom Java plugin, unit tests

8 years agosonar java plugin: unit tests
Gustavo Martin Morcuende [Mon, 22 Aug 2016 19:28:23 +0000 (21:28 +0200)]
sonar java plugin: unit tests

8 years agoJPA project: maven site and Javadoc working
Gustavo Martin Morcuende [Mon, 22 Aug 2016 17:52:23 +0000 (19:52 +0200)]
JPA project: maven site and Javadoc working

8 years agoSonarQube JavaScript custom plugin, improvements in description
Gustavo Martin Morcuende [Sun, 21 Aug 2016 21:20:57 +0000 (23:20 +0200)]
SonarQube JavaScript custom plugin, improvements in description

8 years agosonar JavaScript plugin: use always interfaces.
Gustavo Martin Morcuende [Sun, 21 Aug 2016 20:21:52 +0000 (22:21 +0200)]
sonar JavaScript plugin: use always interfaces.

Otherwise problems with cast because implementations are loaded in different class loaders and my
plugin is not able to see the class loader where the instance was created :/

8 years agosonar JavaScript plugin: AngularJS $rootScope.$on detection
Gustavo Martin Morcuende [Sun, 21 Aug 2016 18:58:23 +0000 (20:58 +0200)]
sonar JavaScript plugin: AngularJS $rootScope.$on detection

8 years agosonar Java plugin: no time for comments
Gustavo Martin Morcuende [Sun, 21 Aug 2016 17:11:47 +0000 (19:11 +0200)]
sonar Java plugin: no time for comments

8 years agosonar Java plugin: multiple improvements
Gustavo Martin Morcuende [Sun, 21 Aug 2016 16:33:13 +0000 (18:33 +0200)]
sonar Java plugin: multiple improvements

8 years agosonar Java plugin, no time for comments
Gustavo Martin Morcuende [Sun, 21 Aug 2016 04:20:27 +0000 (06:20 +0200)]
sonar Java plugin, no time for comments

8 years agosonar JavaScript plugin: any class extending CustomJavaScriptRulesDefinition will...
Gustavo Martin Morcuende [Sun, 21 Aug 2016 04:17:50 +0000 (06:17 +0200)]
sonar JavaScript plugin: any class extending CustomJavaScriptRulesDefinition will be injected and used in JavaScriptSquidSensor.

So as in the Java plugin, I do not have to do anything :) Every time JavaScriptSquidSensor finds JavaScript code my rules will run.

8 years agosonar Java plugin: non required Sensor because we will be running whenever JavaSquidS...
Gustavo Martin Morcuende [Sun, 21 Aug 2016 03:27:37 +0000 (05:27 +0200)]
sonar Java plugin: non required Sensor because we will be running whenever JavaSquidSensor runs

JavaSquidSensor calls CustomRulesCheckRegistrar

8 years agosonar custom Java plugin: some improvements
Gustavo Martin Morcuende [Fri, 19 Aug 2016 19:18:21 +0000 (21:18 +0200)]
sonar custom Java plugin: some improvements

8 years agosonar custom java plugin: removing non required dependency
Gustavo Martin Morcuende [Wed, 17 Aug 2016 16:42:26 +0000 (18:42 +0200)]
sonar custom java plugin: removing non required dependency