use of org.geotoolkit.ows.xml.v200.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchSagaControllerTest method testGetSagaPaginated_givenSearchCriteria_shouldReturnStatusOk.
@Test
@SuppressWarnings("java:S100")
public void testGetSagaPaginated_givenSearchCriteria_shouldReturnStatusOk() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("mock_multiple_sagas.json")).getFile());
final List<Saga> sagaStructs = new ObjectMapper().readValue(file, new TypeReference<>() {
});
final List<ca.bc.gov.educ.penreg.api.model.v1.Saga> sagaEntities = sagaStructs.stream().map(mapper::toModel).collect(Collectors.toList());
for (val saga : sagaEntities) {
saga.setSagaId(null);
saga.setCreateDate(LocalDateTime.now());
saga.setUpdateDate(LocalDateTime.now());
}
this.repository.saveAll(sagaEntities);
final SearchCriteria criteria = SearchCriteria.builder().key("sagaState").operation(FilterOperation.IN).value("IN_PROGRESS").valueType(ValueType.STRING).build();
final SearchCriteria criteria2 = SearchCriteria.builder().key("sagaName").condition(AND).operation(FilterOperation.EQUAL).value("PEN_REQUEST_BATCH_ARCHIVE_AND_RETURN_SAGA").valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList = new ArrayList<>();
criteriaList.add(criteria);
criteriaList.add(criteria2);
final List<Search> searches = new LinkedList<>();
searches.add(Search.builder().searchCriteriaList(criteriaList).build());
final ObjectMapper objectMapper = new ObjectMapper();
final String criteriaJSON = objectMapper.writeValueAsString(searches);
final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch-saga/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "PEN_REQUEST_BATCH_READ_SAGA"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.content", hasSize(1)));
}
use of org.geotoolkit.ows.xml.v200.ValueType in project ddf by codice.
the class TestWfsSource method testSortingAscendingSortingNotSupported.
/**
* Verify that the SortBy is NOT set. In this case, sorting is not supported in the capabilities.
*/
@Test
public void testSortingAscendingSortingNotSupported() throws Exception {
// Setup
final String searchPhrase = "*";
final String mockTemporalFeatureProperty = "myTemporalFeatureProperty";
final String mockFeatureType = "{http://example.com}" + SAMPLE_FEATURE_NAME + 0;
final int pageSize = 1;
// Set ImplementsSorting to FALSE (sorting not supported)
FilterCapabilities mockCapabilitiesSortingNotSupported = MockWfsServer.getFilterCapabilities();
ConformanceType conformance = mockCapabilitiesSortingNotSupported.getConformance();
List<DomainType> domainTypes = conformance.getConstraint();
for (DomainType domainType : domainTypes) {
if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
ValueType valueType = new ValueType();
valueType.setValue("FALSE");
domainType.setDefaultValue(valueType);
break;
}
}
WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, mockCapabilitiesSortingNotSupported, GeospatialUtil.EPSG_4326_URN, 1, false, false, 0);
MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
List<MetacardMapper> mappers = new ArrayList<MetacardMapper>(1);
mappers.add(mockMetacardMapper);
source.setMetacardToFeatureMapper(mappers);
QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
query.setPageSize(pageSize);
SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
query.setSortBy(sortBy);
// Perform Test
GetFeatureType featureType = source.buildGetFeatureRequest(query);
// Verify
QueryType queryType = (QueryType) featureType.getAbstractQueryExpression().get(0).getValue();
assertFalse(queryType.isSetAbstractSortingClause());
}
use of org.geotoolkit.ows.xml.v200.ValueType in project ddf by codice.
the class TestWfsFilterDelegate method testConformanceAllowedValues.
@Test
public void testConformanceAllowedValues() {
// Setup
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
ConformanceType conformance = capabilities.getConformance();
List<DomainType> domainTypes = conformance.getConstraint();
for (DomainType domainType : domainTypes) {
if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
domainType.setNoValues(null);
ValueType asc = new ValueType();
asc.setValue("ASC");
ValueType desc = new ValueType();
desc.setValue("DESC");
AllowedValues allowedValues = new AllowedValues();
List<Object> values = new ArrayList<>();
values.add(asc);
values.add(desc);
allowedValues.setValueOrRange(values);
domainType.setAllowedValues(allowedValues);
ValueType defaultValue = new ValueType();
defaultValue.setValue("ASC");
domainType.setDefaultValue(defaultValue);
break;
}
}
// Perform Test
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
// Verify
assertThat(delegate.isSortingSupported(), is(true));
assertThat(delegate.getAllowedSortOrders().size(), is(2));
assertThat(delegate.getAllowedSortOrders().contains(SortOrder.ASCENDING), is(true));
assertThat(delegate.getAllowedSortOrders().contains(SortOrder.DESCENDING), is(true));
}
use of org.geotoolkit.ows.xml.v200.ValueType in project tck by dmn-tck.
the class CamundaTCKTest method getValue.
private Object getValue(ValueType valueType) {
final JAXBElement<Object> value = valueType.getValue();
final JAXBElement<ValueType.List> listValue = valueType.getList();
final List<Component> componentValue = valueType.getComponent();
if (value == null && listValue == null && componentValue == null) {
return null;
}
if (listValue != null) {
final List<Object> list = new ArrayList<>();
for (ValueType item : listValue.getValue().getItem()) {
list.add(getValue(item));
}
return list;
}
if (componentValue != null && !componentValue.isEmpty()) {
final Map<String, Object> context = new HashMap<>();
for (Component component : componentValue) {
final Object compValue = getValue(component);
context.put(component.getName(), compValue);
}
return context;
}
if (value instanceof Node) {
final Node node = (Node) value;
final String text = node.getFirstChild().getTextContent();
if ("true".equalsIgnoreCase(text) || "false".equalsIgnoreCase(text)) {
return Boolean.valueOf(text);
}
try {
return Long.valueOf(text);
} catch (NumberFormatException e) {
}
try {
return Double.valueOf(text);
} catch (NumberFormatException e) {
}
return text;
}
if (value != null) {
final Object singleValue = value.getValue();
if (singleValue instanceof XMLGregorianCalendar) {
return transformDateTime((XMLGregorianCalendar) singleValue);
}
if (singleValue instanceof Duration) {
return transformDuration((Duration) singleValue);
}
if (singleValue instanceof String[]) {
String[] array = (String[]) singleValue;
return Arrays.asList(array);
}
return singleValue;
}
throw new RuntimeException(String.format("Unexpected value: '%s'", valueType));
}
use of org.geotoolkit.ows.xml.v200.ValueType in project sldeditor by robward-scisys.
the class CustomProcessFunctionTest method createProcessDescriptionEnum.
/**
* Test the process description enumeration values.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void createProcessDescriptionEnum() {
ProcessDescriptionType process = Wps10FactoryImpl.init().createProcessDescriptionType();
CodeType codeType = Ows11FactoryImpl.init().createCodeType();
codeType.setValue("JTS:area");
process.setIdentifier(codeType);
InputDescriptionType inputDescription = Wps10FactoryImpl.init().createInputDescriptionType();
CodeType codeType2 = Ows11FactoryImpl.init().createCodeType();
codeType2.setValue("dummyParameter");
inputDescription.setIdentifier(codeType2);
inputDescription.setMinOccurs(BigInteger.valueOf(1));
inputDescription.setMaxOccurs(BigInteger.valueOf(1));
AllowedValuesType allowedValues = Ows11FactoryImpl.init().createAllowedValuesType();
EList allowedValueList = allowedValues.getValue();
ValueType item1 = Ows11FactoryImpl.init().createValueType();
item1.setValue("item 1");
allowedValueList.add(item1);
ValueType item2 = Ows11FactoryImpl.init().createValueType();
item2.setValue("item 2");
allowedValueList.add(item2);
ValueType item3 = Ows11FactoryImpl.init().createValueType();
item1.setValue("item 3");
allowedValueList.add(item3);
LiteralInputType literal = Wps10FactoryImpl.init().createLiteralInputType();
literal.setAllowedValues(allowedValues);
inputDescription.setLiteralData(literal);
DataInputsType dataInputs = Wps10FactoryImpl.init().createDataInputsType();
EList dataInputList = dataInputs.getInput();
dataInputList.add(inputDescription);
process.setDataInputs(dataInputs);
CustomProcessFunction obj = new CustomProcessFunction();
List<ProcessFunctionParameterValue> valueList = obj.extractParameters(process);
assertEquals(1, valueList.size());
ProcessFunctionParameterValue value = valueList.get(0);
assertEquals(1, value.getMinOccurences());
assertEquals(1, value.getMaxOccurences());
}
Aggregations