@Test public void testCopyFieldAccuracy() throws Exception { SchemaRequest.CopyFields copyFieldsSchemaRequest = new SchemaRequest.CopyFields(); SchemaResponse.CopyFieldsResponse initialCopyFieldsResponse = copyFieldsSchemaRequest.process(getSolrClient()); List<Map<String, Object>> initialCopyFieldsAttributes = initialCopyFieldsResponse.getCopyFields(); String srcFieldName = "copyfield"; String destFieldName1 = "destField1", destFieldName2 = "destField2"; createStoredStringField(srcFieldName, getSolrClient()); createStoredStringField(destFieldName1, getSolrClient()); createStoredStringField(destFieldName2, getSolrClient()); SchemaRequest.AddCopyField addCopyFieldRequest = new SchemaRequest.AddCopyField(srcFieldName, Arrays.asList(destFieldName1, destFieldName2)); SchemaResponse.UpdateResponse addCopyFieldResponse = addCopyFieldRequest.process(getSolrClient()); assertValidSchemaResponse(addCopyFieldResponse); SchemaResponse.CopyFieldsResponse currentCopyFieldsResponse = copyFieldsSchemaRequest.process(getSolrClient()); List<Map<String, Object>> currentCopyFields = currentCopyFieldsResponse.getCopyFields(); assertEquals(initialCopyFieldsAttributes.size() + 2, currentCopyFields.size()); }
@Test public void testGetCopyFieldsAccuracy() throws Exception { SchemaRequest.CopyFields copyFieldsRequest = new SchemaRequest.CopyFields(); SchemaResponse.CopyFieldsResponse copyFieldsResponse = copyFieldsRequest.process(getSolrClient()); assertValidSchemaResponse(copyFieldsResponse); List<Map<String, Object>> copyFieldsAttributes = copyFieldsResponse.getCopyFields(); assertThat(copyFieldsAttributes.isEmpty(), is(false)); }
@Test public void testCopyFieldWithMaxCharsAccuracy() throws Exception { SchemaRequest.CopyFields copyFieldsSchemaRequest = new SchemaRequest.CopyFields(); SchemaResponse.CopyFieldsResponse initialCopyFieldsResponse = copyFieldsSchemaRequest.process(getSolrClient()); List<Map<String, Object>> initialCopyFieldsAttributes = initialCopyFieldsResponse.getCopyFields(); String srcFieldName = "copyfield"; String destFieldName1 = "destField1", destFieldName2 = "destField2"; createStoredStringField(srcFieldName, getSolrClient()); createStoredStringField(destFieldName1, getSolrClient()); createStoredStringField(destFieldName2, getSolrClient()); Integer maxChars = 200; SchemaRequest.AddCopyField addCopyFieldRequest = new SchemaRequest.AddCopyField( srcFieldName, Arrays.asList(destFieldName1, destFieldName2), maxChars); SchemaResponse.UpdateResponse addCopyFieldResponse = addCopyFieldRequest.process(getSolrClient()); assertValidSchemaResponse(addCopyFieldResponse); SchemaResponse.CopyFieldsResponse currentCopyFieldsResponse = copyFieldsSchemaRequest.process(getSolrClient()); List<Map<String, Object>> currentCopyFields = currentCopyFieldsResponse.getCopyFields(); assertEquals(initialCopyFieldsAttributes.size() + 2, currentCopyFields.size()); for (Map<String, Object> currentCopyField : currentCopyFields) { if (srcFieldName.equals(currentCopyField.get("source"))) { String currentDestFieldName = (String) currentCopyField.get("dest"); int currentMaxChars = (Integer) currentCopyField.get("maxChars"); assertThat( currentDestFieldName, anyOf(is(equalTo(destFieldName1)), is(equalTo(destFieldName2)))); assertTrue(maxChars == currentMaxChars); } } }