/** @see DATASOLR-72 */
  @Test
  public void loadExistingSchemaShouldMapSchemaInformationCorrectly() {

    setUpJsonResponse(JSON_RESPONSE_DEFAULT_SCHEMA);
    SchemaDefinition schemaDef = writer.loadExistingSchema("collection1");

    Assert.assertEquals("example", schemaDef.getName());
    Assert.assertEquals("id", schemaDef.getUniqueKey());
  }
  /** @see DATASOLR-72 */
  @Test
  public void schemaPresentCheckSouldIndicateFalseWhenServerReturnsNotFound()
      throws SolrServerException, IOException {

    Mockito.when(solrServerMock.request(Mockito.any(SolrRequest.class)))
        .thenThrow(
            new SolrServerException(
                new SolrException(
                    org.apache.solr.common.SolrException.ErrorCode.NOT_FOUND, "boom")));
    Assert.assertFalse(writer.isSchemaPresent("collection1"));
  }
  /** @see DATASOLR-72 */
  @Test
  public void loadExistingSchemaShouldMapFieldInformationCorrectly() {

    setUpJsonResponse(JSON_RESPONSE_DEFAULT_SCHEMA);
    FieldDefinition fieldDef = writer.loadExistingSchema("collection1").getFieldDefinition("id");

    Assert.assertEquals("id", fieldDef.getName());
    Assert.assertEquals("string", fieldDef.getType());
    Assert.assertEquals(false, fieldDef.isMultiValued());
    Assert.assertEquals(true, fieldDef.isIndexed());
    Assert.assertEquals(true, fieldDef.isRequired());
    Assert.assertEquals(true, fieldDef.isStored());
  }
  /** @see DATASOLR-72 */
  @Test
  public void loadExistingSchemaShouldReturnNullWhenNoInformationReturnedFromServer() {

    setUpJsonResponse(INVALID_RESPONSE);
    Assert.assertNull(writer.loadExistingSchema("collection1"));
  }
  /** @see DATASOLR-72 */
  @Test
  public void schemaPresentCheckSouldReturnTrueIfVersionCorrectlyReturnedFromServer() {

    setUpJsonResponse(JSON_RESPONSE_SCHEMA_VERSION);
    Assert.assertTrue(writer.isSchemaPresent("collection1"));
  }
 /** @see DATASOLR-72 */
 @Test(expected = UnsupportedOperationException.class)
 public void schemaCreationIsCurrentlyNotPossible() {
   writer.createSchema(new SchemaDefinition());
 }
  /** @see DATASOLR-72 */
  @Test
  public void loadExistingSchemaShouldMapEmptySchemaCorrectly() {

    setUpJsonResponse(JSON_RESPONSE_EMPTY_SCHEMA);
    Assert.assertNotNull(writer.loadExistingSchema("collection1"));
  }