DocumentTypeChangeValidator { public List<VespaConfigChangeAction> validate(ValidationOverrides overrides, Instant now) { return currentDocType.getAllFields().stream(). map(field -> createFieldChange(field, nextDocType)). filter(fieldChange -> fieldChange.valid() && fieldChange.changedType()). map(fieldChange -> VespaRefeedAction.of("field-type-change", overrides, new ChangeMessageBuilder(fieldChange.fieldName()). addChange("data type", fieldChange.currentTypeName(), fieldChange.nextTypeName()).build(), now)). collect(Collectors.toList()); } DocumentTypeChangeValidator(NewDocumentType currentDocType,
                                       NewDocumentType nextDocType); List<VespaConfigChangeAction> validate(ValidationOverrides overrides, Instant now);  }
@Test public void requireThatChangingTargetTypeOfReferenceFieldIsNotOK() { DocumentTypeChangeValidator validator = new DocumentTypeChangeValidator( createDocumentTypeWithReferenceField("oldDoc"), createDocumentTypeWithReferenceField("newDoc")); List<VespaConfigChangeAction> result = validator.validate(ValidationOverrides.empty, Instant.now()); assertEquals(1, result.size()); VespaConfigChangeAction action = result.get(0); assertTrue(action instanceof VespaRefeedAction); assertEquals( "type='refeed', " + "message='Field 'ref' changed: data type: 'Reference<oldDoc>' -> 'Reference<newDoc>'', " + "services=[], documentType=''", action.toString()); }