 
     func testCreateClassifierWithMissingMetadata() {
         let expectation = self.expectation(description: "Create a classifier with missing metadata")
-        let failure = { (error: Error) in expectation.fulfill() }
         naturalLanguageClassifier.createClassifier(
             metadata: metadataFileEmpty,
-            trainingData: trainingFile,
-            failure: failure,
-            success: failWithResult)
+            trainingData: trainingFile
+        ) {
+                _, error in
+
+                if error == nil {
+                    XCTFail("Expected error response")
+                }
+                expectation.fulfill()
+        }
         waitForExpectations()
     }
 
     func testClassifyEmptyString() {
         let expectation = self.expectation(description: "Classify and empty string.")
-        let failure = { (error: Error) in expectation.fulfill() }
-        naturalLanguageClassifier.classify(classifierID: trainedClassifierId, text: "", failure: failure, success: failWithResult)
+        naturalLanguageClassifier.classify(classifierID: trainedClassifierId, text: "") {
+            _, error in
+
+            if error == nil {
+                XCTFail("Expected error response")
+            }
+            expectation.fulfill()
+        }
         waitForExpectations()
     }
 
     func testClassifyWithInvalidClassifier() {
         let expectation = self.expectation(description: "Classify using an invalid classifier id.")
-        let failure = { (error: Error) in expectation.fulfill() }
         naturalLanguageClassifier.classify(
             classifierID: "this-is-an-invalid-classifier-id",
-            text: "How hot will it be today?",
-            failure: failure,
-            success: failWithResult
-        )
+            text: "How hot will it be today?"
+        ) {
+            _, error in
+
+            if error == nil {
+                XCTFail("Expected error response")
+            }
+            expectation.fulfill()
+        }
         waitForExpectations()
     }
 
     func testDeleteInvalidClassifier() {
         let expectation = self.expectation(description: "Delete a classifier using an invalid classifier id.")
-        let failure = { (error: Error) in expectation.fulfill() }
         naturalLanguageClassifier.deleteClassifier(
-            classifierID: "this-is-an-invalid-classifier-id",
-            failure: failure,
-            success: failWithResult
-        )
+            classifierID: "this-is-an-invalid-classifier-id"
+        ) {
+            _, error in
+
+            if error == nil {
+                XCTFail("Expected error response")
+            }
+            expectation.fulfill()
+        }
         waitForExpectations()
     }
 
     func testGetInvalidClassifier() {
         let expectation = self.expectation(description: "Get classifier using an invalid classifier id.")
-        let failure = { (error: Error) in expectation.fulfill() }
         naturalLanguageClassifier.getClassifier(
-            classifierID: "this-is-an-invalid-classifier-id",
-            failure: failure,
-            success: failWithResult
-        )
+            classifierID: "this-is-an-invalid-classifier-id"
+        ) {
+            _, error in
+
+            if error == nil {
+                XCTFail("Expected error response")
+            }
+            expectation.fulfill()
+        }
         waitForExpectations()
     }
 }

        }
        naturalLanguageClassifier.defaultHeaders["X-Watson-Learning-Opt-Out"] = "true"
        naturalLanguageClassifier.defaultHeaders["X-Watson-Test"] = "true"
    }

    /** Fail false negatives. */
    func failWithError(error: Error) {
        XCTFail("Positive test failed with error: \(error)")
    }

    /** Fail false positives. */
    func failWithResult<T>(result: T) {
        XCTFail("Negative test returned a result.")
    }

    /** Fail false positives. */
    func failWithResult() {
        XCTFail("Negative test returned a result.")
    }

    /** Wait for expectations. */


    func testCreateAndDelete() {
        let expectation = self.expectation(description: "Create and delete a classifier")
        naturalLanguageClassifier.createClassifier(metadata: metadataFile, trainingData: trainingFile) {
            response, error in

            if let error = error {
                XCTFail("Unexpected error response from service: \(error)")
                return
            }
            guard let classifier = response?.result else {
                XCTFail("Missing response value")
                return
            }

            XCTAssertEqual(classifier.name, self.temporaryClassifierName)
            XCTAssertEqual(classifier.language, "en")
            self.naturalLanguageClassifier.deleteClassifier(classifierID: classifier.classifierID) {
                _, error in

                if let error = error {
                    XCTFail("Unexpected error response from service: \(error)")
                }
                expectation.fulfill()
            }
        }
