View Javadoc

1   package org.starobjects.tested.fitnesse.internal.fixtures;
2   
3   import java.text.SimpleDateFormat;
4   import java.util.Calendar;
5   
6   import org.nakedobjects.applib.clock.Clock;
7   import org.starobjects.tested.fitnesse.StoryFixture;
8   import org.starobjects.tested.fitnesse.internal.fixtures.bindings.CellBinding;
9   
10  import fit.Fixture;
11  import fit.Parse;
12  
13  public class DebugClock extends AbstractFixture {
14  
15      @SuppressWarnings("unused")
16      private StoryFixture storyFixture;
17  
18      private final CellBinding valueBinding;
19  
20      public DebugClock(final StoryFixture storyFixture) {
21          this(storyFixture, CellBinding.builder(Constants.VALUE_NAME,
22                  Constants.VALUE_HEAD).build());
23      }
24  
25      private DebugClock(final StoryFixture storyFixture,
26              final CellBinding valueBinding) {
27          super(storyFixture, valueBinding);
28          this.valueBinding = valueBinding;
29      }
30  
31      @Override
32      public void doRow(final Parse row) {
33          super.doRow(row);
34          readClock();
35      }
36  
37      public void readClock() {
38          final Calendar cal = Clock.getTimeAsCalendar();
39          final String formattedDate = new SimpleDateFormat("dd-MMM-yyyy HH:mm")
40                  .format(cal.getTime());
41          valueBinding.getCurrentCell().body = Fixture.gray(formattedDate);
42      }
43  
44  }