### Question:
ClassificationValidationUtils { public static void validateClassificationModel(final DatasetSchema schema, final ClassificationMLModel model) throws ModelLoadingException { Preconditions.checkNotNull(schema, "schema cannot be null"); Preconditions.checkNotNull(model, "model cannot be null"); final MockDataset mockDataset = new MockDataset(schema, 1, new Random(0)); try { model.classify(mockDataset.instance(0)); } catch (final RuntimeException e) { final String msg = String.format("Model classification is not compatible with the given schema %s.", schema); logger.error(msg, e); throw new ModelLoadingException(msg, e); } try { model.getClassDistribution(mockDataset.instance(0)); } catch (final RuntimeException e) { final String msg = "Model does not support class distribution."; logger.error(msg, e); throw new ModelLoadingException(msg, e); } } private  ClassificationValidationUtils(); static void validateClassificationModel(final DatasetSchema schema,
                                                   final ClassificationMLModel model); static void validateParamsModelToLoad(final MachineLearningModelLoader modelLoader,
                                                 final Path modelPath,
                                                 final DatasetSchema schema,
                                                 final Map<String, String> params);  }### Answer:
@Test public void testValidModel() { assertThatCode(() -> ClassificationValidationUtils.validateClassificationModel( SCHEMA, getClassificationModelFor( () -> new double[] { 0.25, 0.75 }, () -> 1 ) )).doesNotThrowAnyException(); }
@Test public void testModelInvalidDistribution() { assertThatThrownBy(() -> ClassificationValidationUtils.validateClassificationModel( SCHEMA, getClassificationModelFor( () -> { throw new RuntimeException("Failure to calculate distribution"); }, () -> 1 ) )).isInstanceOf(ModelLoadingException.class); }
@Test public void testModelInvalidClassification() { assertThatThrownBy(() -> ClassificationValidationUtils.validateClassificationModel( SCHEMA, getClassificationModelFor( () -> new double[] { 0.25, 0.75 }, () -> { throw new RuntimeException("Failure to calculate distribution"); } ) )).isInstanceOf(ModelLoadingException.class); }
@Test public void testVoidSchemaOfClassificationModel() { assertThatThrownBy( () -> ClassificationValidationUtils.validateClassificationModel( null, getClassificationModelFor( () -> new double[] { 0.25, 0.75 }, () -> 1 ) )) .isInstanceOf(NullPointerException.class) .hasMessageContaining(NULL_ERROR_MSG); }
@Test public void testVoidClassificationMLModel() { assertThatThrownBy( () -> ClassificationValidationUtils.validateClassificationModel( SCHEMA, null )) .isInstanceOf(NullPointerException.class) .hasMessageContaining(NULL_ERROR_MSG); }