You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InlineDateFieldDeclarativeTest.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.server.component.datefield;
  17. import java.io.ByteArrayInputStream;
  18. import java.io.ByteArrayOutputStream;
  19. import java.time.LocalDate;
  20. import org.junit.Test;
  21. import com.vaadin.tests.server.component.abstractdatefield.AbstractLocalDateFieldDeclarativeTest;
  22. import com.vaadin.ui.AbstractDateField;
  23. import com.vaadin.ui.InlineDateField;
  24. import com.vaadin.ui.declarative.Design;
  25. /**
  26. * Tests the declarative support for implementations of
  27. * {@link AbstractDateField}.
  28. *
  29. * @since 7.4
  30. * @author Vaadin Ltd
  31. */
  32. public class InlineDateFieldDeclarativeTest
  33. extends AbstractLocalDateFieldDeclarativeTest<InlineDateField> {
  34. @Test
  35. public void testInlineDateFieldToFromDesign() throws Exception {
  36. InlineDateField field = new InlineDateField("Day is",
  37. LocalDate.of(2003, 2, 27));
  38. field.setShowISOWeekNumbers(true);
  39. field.setRangeStart(LocalDate.of(2001, 2, 27));
  40. field.setRangeEnd(LocalDate.of(20011, 2, 27));
  41. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  42. Design.write(field, bos);
  43. InlineDateField result = (InlineDateField) Design
  44. .read(new ByteArrayInputStream(bos.toByteArray()));
  45. assertEquals(field.getResolution(), result.getResolution());
  46. assertEquals(field.getCaption(), result.getCaption());
  47. assertEquals(field.getValue(), result.getValue());
  48. assertEquals(field.getRangeStart(), result.getRangeStart());
  49. assertEquals(field.getRangeEnd(), result.getRangeEnd());
  50. }
  51. @Override
  52. protected String getComponentTag() {
  53. return "vaadin-inline-date-field";
  54. }
  55. @Override
  56. protected Class<? extends InlineDateField> getComponentClass() {
  57. return InlineDateField.class;
  58. }
  59. }