Esempio 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"));
 }
Esempio n. 2
0
 @Test
 public void deleteCopyFieldShouldFailWhenOneOfTheFieldsDoesntExistInTheSchema() throws Exception {
   String srcFieldName = "copyfield";
   String destFieldName1 = "destField1", destFieldName2 = "destField2";
   SchemaRequest.DeleteCopyField deleteCopyFieldsRequest =
       new SchemaRequest.DeleteCopyField(
           srcFieldName, Arrays.asList(destFieldName1, destFieldName2));
   SchemaResponse.UpdateResponse deleteCopyFieldResponse =
       deleteCopyFieldsRequest.process(getSolrClient());
   assertNotNull(deleteCopyFieldResponse.getResponse().get("errors"));
 }
Esempio n. 3
0
  @Test
  public void copyFieldsShouldFailWhenOneOfTheFieldsDoesntExistInTheSchema() throws Exception {
    String srcFieldName = "srcnotexist";
    String destFieldName1 = "destNotExist1", destFieldName2 = "destNotExist2";

    SchemaRequest.AddCopyField addCopyFieldRequest =
        new SchemaRequest.AddCopyField(srcFieldName, Arrays.asList(destFieldName1, destFieldName2));
    SchemaResponse.UpdateResponse addCopyFieldResponse =
        addCopyFieldRequest.process(getSolrClient());
    assertNotNull(addCopyFieldResponse.getResponse().get("errors"));
  }
Esempio n. 4
0
  @Test
  public void addFieldShouldntBeCalledTwiceWithTheSameName() throws Exception {
    Map<String, Object> fieldAttributes = new LinkedHashMap<>();
    fieldAttributes.put("name", "failureField");
    fieldAttributes.put("type", "string");
    SchemaRequest.AddField addFieldUpdateSchemaRequest =
        new SchemaRequest.AddField(fieldAttributes);
    SchemaResponse.UpdateResponse addFieldFirstResponse =
        addFieldUpdateSchemaRequest.process(getSolrClient());
    assertValidSchemaResponse(addFieldFirstResponse);

    SchemaResponse.UpdateResponse addFieldSecondResponse =
        addFieldUpdateSchemaRequest.process(getSolrClient());
    assertEquals(0, addFieldSecondResponse.getStatus());
    assertNotNull(addFieldSecondResponse.getResponse().get("errors"));
  }
Esempio n. 5
0
  @Test
  public void addFieldTypeShouldntBeCalledTwiceWithTheSameName() throws Exception {
    Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>();
    fieldTypeAttributes.put("name", "failureInt");
    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);
    SchemaResponse.UpdateResponse addFieldTypeFirstResponse =
        addFieldTypeRequest.process(getSolrClient());
    assertValidSchemaResponse(addFieldTypeFirstResponse);

    SchemaResponse.UpdateResponse addFieldTypeSecondResponse =
        addFieldTypeRequest.process(getSolrClient());
    assertEquals(0, addFieldTypeSecondResponse.getStatus());
    assertNotNull(addFieldTypeSecondResponse.getResponse().get("errors"));
  }