|
| 1 | +package com.quantori.cqp.api.model; |
| 2 | + |
| 3 | +import static org.assertj.core.api.Assertions.assertThat; |
| 4 | + |
| 5 | +import java.time.Instant; |
| 6 | +import java.time.LocalDate; |
| 7 | +import java.util.EnumSet; |
| 8 | +import java.util.List; |
| 9 | +import org.junit.jupiter.api.Test; |
| 10 | + |
| 11 | +class PropertyTypeTest { |
| 12 | + |
| 13 | + @Test |
| 14 | + void shouldContainExtendedTypes() { |
| 15 | + EnumSet<Property.PropertyType> types = EnumSet.allOf(Property.PropertyType.class); |
| 16 | + |
| 17 | + assertThat(types) |
| 18 | + .contains( |
| 19 | + Property.PropertyType.BINARY, |
| 20 | + Property.PropertyType.DATE_TIME, |
| 21 | + Property.PropertyType.LIST, |
| 22 | + Property.PropertyType.HYPERLINK, |
| 23 | + Property.PropertyType.CHEMICAL_STRUCTURE, |
| 24 | + Property.PropertyType.STRUCTURE_3D, |
| 25 | + Property.PropertyType.HTML); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + void shouldAllowPropertyValueAccessors() { |
| 30 | + byte[] binary = new byte[] {1, 2, 3}; |
| 31 | + Instant timestamp = Instant.parse("2024-01-01T10:15:30Z"); |
| 32 | + List<String> orderedList = List.of("first", "second"); |
| 33 | + LocalDate date = LocalDate.of(2024, 2, 29); |
| 34 | + |
| 35 | + PropertyValue value = |
| 36 | + PropertyValue.builder() |
| 37 | + .stringValue("test") |
| 38 | + .decimalValue(12.34d) |
| 39 | + .dateValue(date) |
| 40 | + .binaryValue(binary) |
| 41 | + .dateTimeValue(timestamp) |
| 42 | + .listValue(orderedList) |
| 43 | + .hyperlinkValue("https://example.com") |
| 44 | + .chemicalStructureValue("CCO") |
| 45 | + .structure3DValue("3D-MOL-DATA") |
| 46 | + .htmlValue("<p>html</p>") |
| 47 | + .build(); |
| 48 | + |
| 49 | + assertThat(value.getStringValue()).isEqualTo("test"); |
| 50 | + assertThat(value.getDecimalValue()).isEqualTo(12.34d); |
| 51 | + assertThat(value.getDateValue()).isEqualTo(date); |
| 52 | + assertThat(value.getBinaryValue()).containsExactly(binary); |
| 53 | + assertThat(value.getDateTimeValue()).isEqualTo(timestamp); |
| 54 | + assertThat(value.getListValue()).containsExactlyElementsOf(orderedList); |
| 55 | + assertThat(value.getHyperlinkValue()).isEqualTo("https://example.com"); |
| 56 | + assertThat(value.getChemicalStructureValue()).isEqualTo("CCO"); |
| 57 | + assertThat(value.getStructure3DValue()).isEqualTo("3D-MOL-DATA"); |
| 58 | + assertThat(value.getHtmlValue()).isEqualTo("<p>html</p>"); |
| 59 | + } |
| 60 | +} |
0 commit comments