@Test
  public void testPreservesOptions() {
    Fixture.fakePhase(PhaseId.READ_DATA);
    when(adapter.getFlavor()).thenReturn(NeedsPositionFlavor.CONTINUOUS);
    GeolocationOptions options =
        new GeolocationOptions().setFrequency(10).enableHighAccuracy().setMaximumAge(10);
    when(adapter.getOptions()).thenReturn(options);

    synchronizer.preserveValues(object);

    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId()
                    + "."
                    + GeolocationSynchronizer.PROP_ENABLE_HIGH_ACCURACY));
    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_FREQUENCY));
    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_MAXIMUM_AGE));
  }
  @Test(expected = IllegalStateException.class)
  public void testParseError() {
    when(synchronizer.readPropertyValue(GeolocationSynchronizer.PROP_LATITUDE)).thenReturn("101.1");
    String date = "2012-12-30-20-15-43";
    when(synchronizer.readPropertyValue(GeolocationSynchronizer.PROP_TIMESTAMP)).thenReturn(date);

    synchronizer.readData(object);
  }
  @Test
  public void testReadDataWithError() {
    when(synchronizer.readPropertyValue(GeolocationSynchronizer.PROP_ERROR_CODE))
        .thenReturn("UNKNOWN");

    synchronizer.readData(object);

    verify(adapter).setError(any(PositionError.class));
  }
  @Test
  public void testReadData() {
    when(synchronizer.readPropertyValue(GeolocationSynchronizer.PROP_LATITUDE)).thenReturn("101.1");
    String date = "2012-Dec-30-20-15-43";
    when(synchronizer.readPropertyValue(GeolocationSynchronizer.PROP_TIMESTAMP)).thenReturn(date);

    synchronizer.readData(object);

    verify(adapter).setPosition(any(Position.class));
  }
  @Test
  public void testPreservesValues() {
    Fixture.fakePhase(PhaseId.READ_DATA);
    when(adapter.getFlavor()).thenReturn(NeedsPositionFlavor.CONTINUOUS);
    synchronizer.preserveValues(object);

    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_NEEDS_POSITION));
  }
  @Test
  public void testDestroy() {
    IClientObject clientObject = mock(IClientObject.class);

    synchronizer.destroy(clientObject);

    verify(clientObject).destroy();
  }
  @Test
  public void testRenderInitialization() {
    IClientObject clientObject = mock(IClientObject.class);

    synchronizer.renderInitialization(clientObject, object);

    verify(clientObject).create(GeolocationSynchronizer.TYPE);
  }
  @Test
  public void testProcessActionWithContinous() {
    when(adapter.getFlavor()).thenReturn(NeedsPositionFlavor.CONTINUOUS);
    Position position = mock(Position.class);
    when(adapter.getPosition()).thenReturn(position);
    GeolocationCallback callback = mock(GeolocationCallback.class);
    when(adapter.getCallback()).thenReturn(callback);

    synchronizer.processAction(object);

    verify(callback).onSuccess(position);
    verify(adapter).setPosition(null);
    verify(adapter, never()).setCallback(null);
    verify(adapter, never()).setOptions(null);
    verify(adapter, never()).setFlavor(NeedsPositionFlavor.NEVER);
  }
  @Test
  public void testRenderChanges() {
    Fixture.fakePhase(PhaseId.READ_DATA);
    when(adapter.getFlavor()).thenReturn(NeedsPositionFlavor.CONTINUOUS);
    GeolocationOptions options =
        new GeolocationOptions().setFrequency(10).enableHighAccuracy().setMaximumAge(10);
    when(adapter.getOptions()).thenReturn(options);

    synchronizer.renderChanges(object);

    verify(synchronizer)
        .renderProperty(
            eq(GeolocationSynchronizer.PROP_NEEDS_POSITION),
            any(NeedsPositionFlavor.class),
            any(NeedsPositionFlavor.class));
    verify(synchronizer)
        .renderProperty(
            eq(GeolocationSynchronizer.PROP_MAXIMUM_AGE), any(Integer.class), any(Integer.class));
    verify(synchronizer)
        .renderProperty(
            eq(GeolocationSynchronizer.PROP_FREQUENCY), any(Integer.class), any(Integer.class));
  }