Ejemplo n.º 1
0
 @Test
 public void deletingAFieldThatDoesntExistInTheSchemaShouldFail() throws Exception {
   SchemaRequest.DeleteField deleteFieldRequest =
       new SchemaRequest.DeleteField("fieldToBeDeleted");
   SchemaResponse.UpdateResponse deleteFieldResponse = deleteFieldRequest.process(getSolrClient());
   assertNotNull(deleteFieldResponse.getResponse().get("errors"));
 }
Ejemplo n.º 2
0
  @Test
  public void testDeleteFieldAccuracy() throws Exception {
    String fieldName = "fieldToBeDeleted";
    Map<String, Object> fieldAttributesRequest = new LinkedHashMap<>();
    fieldAttributesRequest.put("name", fieldName);
    fieldAttributesRequest.put("type", "string");
    SchemaRequest.AddField addFieldUpdateSchemaRequest =
        new SchemaRequest.AddField(fieldAttributesRequest);
    SchemaResponse.UpdateResponse addFieldResponse =
        addFieldUpdateSchemaRequest.process(getSolrClient());
    assertValidSchemaResponse(addFieldResponse);

    SchemaRequest.Field fieldSchemaRequest = new SchemaRequest.Field(fieldName);
    SchemaResponse.FieldResponse initialFieldResponse = fieldSchemaRequest.process(getSolrClient());
    assertValidSchemaResponse(initialFieldResponse);
    Map<String, Object> fieldAttributesResponse = initialFieldResponse.getField();
    assertThat(fieldName, is(equalTo(fieldAttributesResponse.get("name"))));

    SchemaRequest.DeleteField deleteFieldRequest = new SchemaRequest.DeleteField(fieldName);
    SchemaResponse.UpdateResponse deleteFieldResponse = deleteFieldRequest.process(getSolrClient());
    assertValidSchemaResponse(deleteFieldResponse);

    try {
      fieldSchemaRequest.process(getSolrClient());
      fail(
          String.format(
              Locale.ROOT,
              "after removal, the field %s shouldn't be anymore available over Schema API",
              fieldName));
    } catch (SolrException e) {
      // success
    }
  }