--- /dev/null
+package org.craftedsw.feature;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+public class ClockGus {
+
+ private static final DateTimeFormatter DD_MM_YYYY = DateTimeFormatter.ofPattern("dd/MM/yyyy");
+
+ public String todayAsString() {
+ return formattedToday(LocalDate.now());
+ }
+
+ protected String formattedToday(LocalDate date) {
+ return date.format(DD_MM_YYYY);
+ }
+}
--- /dev/null
+package org.craftedsw.feature;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+import org.junit.Test;
+
+public class ClockGusShould {
+ private static final DateTimeFormatter DD_MM_YYYY = DateTimeFormatter.ofPattern("dd/MM/yyyy");
+
+ @Test public void
+ return_todays_date_in_dd_MM_yyyy_format() {
+ ClockGus clock = spy(new ClockGus());
+ LocalDate today = today();
+ given(clock.formattedToday(today)).willReturn(today.format(DD_MM_YYYY));
+
+ String date = clock.todayAsString();
+
+ assertThat(date, is(today.format(DD_MM_YYYY)));
+ verify(clock, times(1)).formattedToday(today);
+ }
+
+ @Test public void
+ return_date_in_dd_MM_yyyy_format() {
+ ClockGus clock = new ClockGus();
+ LocalDate today = today();
+
+ String date = clock.formattedToday(today);
+
+ assertThat(date, is(today.format(DD_MM_YYYY)));
+ }
+
+ private LocalDate today() {
+ return LocalDate.now();
+ }
+}