use of org.kie.workbench.common.dmn.api.editors.types.DMNSimpleTimeZone in project kie-wb-common by kiegroup.
the class TimeZoneServiceImpl method getTimeZones.
@Override
public List<DMNSimpleTimeZone> getTimeZones() {
final String[] ids = getAvailableIds();
final ArrayList<DMNSimpleTimeZone> list = new ArrayList<>(ids.length);
for (final String id : ids) {
final TimeZone timeZone = getTimeZone(id);
final DMNSimpleTimeZone simpleTimeZone = new DMNSimpleTimeZone();
simpleTimeZone.setId(id);
final double offset = toHours(timeZone.getRawOffset());
simpleTimeZone.setOffset(offset);
simpleTimeZone.setOffsetString(formatOffset(offset));
list.add(simpleTimeZone);
}
return list;
}
use of org.kie.workbench.common.dmn.api.editors.types.DMNSimpleTimeZone in project kie-wb-common by kiegroup.
the class TimeSelectorView method populateTimeZoneSelectorWithIds.
void populateTimeZoneSelectorWithIds() {
RemoveHelper.removeChildren(timeZoneSelector);
timeZoneSelector.appendChild(createNoneOption());
for (int i = 0; i < getTimeZones().size(); i++) {
final DMNSimpleTimeZone timeZone = getTimeZones().get(i);
final HTMLOptionElement option = createOptionWithId(timeZone);
timeZoneSelector.appendChild(option);
}
setPickerValue(getSelectPicker(), getTimeZoneSelectedValue());
timeZoneSelectorRefresh();
}
use of org.kie.workbench.common.dmn.api.editors.types.DMNSimpleTimeZone in project kie-wb-common by kiegroup.
the class TimeZoneServiceImplTest method testGetTimeZones.
@Test
public void testGetTimeZones() {
final TimeZone timeZone0 = mock(TimeZone.class);
final TimeZone timeZone1 = mock(TimeZone.class);
final String[] ids = new String[] { "0", "1" };
when(timeZone0.getRawOffset()).thenReturn(0);
when(timeZone1.getRawOffset()).thenReturn(3600000);
doReturn(ids).when(service).getAvailableIds();
doReturn(timeZone0).when(service).getTimeZone("0");
doReturn(timeZone1).when(service).getTimeZone("1");
final List<DMNSimpleTimeZone> simpleTimeZones = service.getTimeZones();
assertEquals(2, simpleTimeZones.size());
assertEquals(0, simpleTimeZones.get(0).getOffset(), 0.01d);
assertEquals(1, simpleTimeZones.get(1).getOffset(), 0.01d);
assertEquals("+00:00", simpleTimeZones.get(0).getOffsetString());
assertEquals("+01:00", simpleTimeZones.get(1).getOffsetString());
}
use of org.kie.workbench.common.dmn.api.editors.types.DMNSimpleTimeZone in project kie-wb-common by kiegroup.
the class TimeSelectorViewTest method testCreateOptionWithId.
@Test
public void testCreateOptionWithId() {
final String optionId = "some id";
final HTMLOptionElement option = new HTMLOptionElement();
final DMNSimpleTimeZone tz = new DMNSimpleTimeZone();
tz.setId(optionId);
doReturn(option).when(view).getNewOption();
view.createOptionWithId(tz);
assertEquals(optionId, option.value);
assertEquals(optionId, option.text);
}
use of org.kie.workbench.common.dmn.api.editors.types.DMNSimpleTimeZone in project kie-wb-common by kiegroup.
the class TimeSelectorViewTest method testPopulateTimeZoneSelectorWithIds.
@Test
public void testPopulateTimeZoneSelectorWithIds() {
final HTMLOptionElement noneOption = mock(HTMLOptionElement.class);
final HTMLOptionElement tz1Option = mock(HTMLOptionElement.class);
final HTMLOptionElement tz2Option = mock(HTMLOptionElement.class);
final List<DMNSimpleTimeZone> timeZones = mock(List.class);
final DMNSimpleTimeZone tz1 = mock(DMNSimpleTimeZone.class);
final DMNSimpleTimeZone tz2 = mock(DMNSimpleTimeZone.class);
when(tz1.getId()).thenReturn("time zone 1");
when(tz2.getId()).thenReturn("other time zone");
when(timeZones.size()).thenReturn(2);
when(timeZones.get(0)).thenReturn(tz1);
when(timeZones.get(1)).thenReturn(tz2);
doReturn(tz1Option).when(view).createOptionWithId(tz1);
doReturn(tz2Option).when(view).createOptionWithId(tz2);
doReturn(timeZones).when(view).getTimeZones();
doReturn(noneOption).when(view).createNoneOption();
doNothing().when(view).timeZoneSelectorRefresh();
view.populateTimeZoneSelectorWithIds();
verify(timeZoneSelector).appendChild(noneOption);
verify(timeZoneSelector).appendChild(tz1Option);
verify(timeZoneSelector).appendChild(tz2Option);
verify(view).timeZoneSelectorRefresh();
}
Aggregations