@Test public void deletingAFieldTypeThatDoesntExistInTheSchemaShouldFail() throws Exception { SchemaRequest.DeleteFieldType deleteFieldTypeRequest = new SchemaRequest.DeleteFieldType("fieldTypeToBeDeleted"); SchemaResponse.UpdateResponse deleteFieldResponse = deleteFieldTypeRequest.process(getSolrClient()); assertNotNull(deleteFieldResponse.getResponse().get("errors")); }
@Test public void testDeleteFieldTypeAccuracy() throws Exception { Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>(); String fieldTypeName = "delInt"; fieldTypeAttributes.put("name", fieldTypeName); fieldTypeAttributes.put("class", "solr.TrieIntField"); fieldTypeAttributes.put("precisionStep", 0); fieldTypeAttributes.put("omitNorms", true); fieldTypeAttributes.put("positionIncrementGap", 0); FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition(); fieldTypeDefinition.setAttributes(fieldTypeAttributes); SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition); SolrClient c = getSolrClient(); SchemaResponse.UpdateResponse addFieldTypeResponse = addFieldTypeRequest.process(c); assertValidSchemaResponse(addFieldTypeResponse); SchemaRequest.FieldType fieldTypeRequest = new SchemaRequest.FieldType(fieldTypeName); SchemaResponse.FieldTypeResponse initialFieldTypeResponse = fieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(initialFieldTypeResponse); FieldTypeRepresentation responseFieldTypeRepresentation = initialFieldTypeResponse.getFieldType(); assertThat( fieldTypeName, is(equalTo(responseFieldTypeRepresentation.getAttributes().get("name")))); SchemaRequest.DeleteFieldType deleteFieldTypeRequest = new SchemaRequest.DeleteFieldType(fieldTypeName); SchemaResponse.UpdateResponse deleteFieldTypeResponse = deleteFieldTypeRequest.process(getSolrClient()); assertValidSchemaResponse(deleteFieldTypeResponse); try { fieldTypeRequest.process(getSolrClient()); fail( String.format( Locale.ROOT, "after removal, the field type %s shouldn't be anymore available over Schema API", fieldTypeName)); } catch (SolrException e) { // success } }