当前位置: 首页>>代码示例>>Java>>正文


Java Fail类代码示例

本文整理汇总了Java中org.fest.assertions.Fail的典型用法代码示例。如果您正苦于以下问题:Java Fail类的具体用法?Java Fail怎么用?Java Fail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Fail类属于org.fest.assertions包,在下文中一共展示了Fail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: currentUser_AuthorizedRequest_Ok

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void currentUser_AuthorizedRequest_Ok() {

    User user = new User("[email protected]", "password", "John", "Doe");
    user.save();

    Result result = callAction(routes.ref.UserController.currentUser(),
            authorizeRequest(fakeRequest(), user));
    assertThat(status(result)).isEqualTo(Http.Status.OK);

    try {
        JsonNode responseJson = JsonHelper.removeRootElement(Json.parse(contentAsString(result)), User.class, false);
        assertThat(Json.fromJson(responseJson, User.class)).isEqualTo(user);
    } catch (JsonHelper.InvalidJSONException e) {
        e.printStackTrace();
        Fail.fail(e.getMessage());
    }
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:19,代码来源:UserTest.java

示例2: shouldBuildAndApplyCreationPatch

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void shouldBuildAndApplyCreationPatch() {
    //Testing.Print.enable();
    
    Document initial = Document.create("firstName", "Jackie", "lastName", "Jones");
    Patch<EntityId> patch = Patch.create(ENTITY_ID, initial);
    assertThat(patch.isCreation()).isTrue();
    
    Document result = Document.create();
    patch.apply(result, (path,op)->Fail.fail("Unable to apply op"));
    Testing.print("patch = " + patch);
    Testing.print("result = " + result);
    assertThat(result.getString("firstName")).isEqualTo("Jackie");
    assertThat(result.getString("lastName")).isEqualTo("Jones");
    assertThat(Message.getId(result)).isEqualTo(ENTITY_ID);
}
 
开发者ID:rhauch,项目名称:debezium-proto,代码行数:17,代码来源:PatchTest.java

示例3: shouldBuildAndApplyPatchToAddSimpleFieldsToEntity

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void shouldBuildAndApplyPatchToAddSimpleFieldsToEntity() {
    //Testing.Print.enable();
    
    Patch<EntityId> patch = Patch.edit(ENTITY_ID)
            .add("firstName", Value.create("Jackie"))
            .add("lastName", Value.create("Jones"))
            .end();
    assertThat(patch.isCreation()).isFalse();

    // Apply the patch ....
    Document doc = Document.create();
    Message.addId(doc, ENTITY_ID);
    patch.apply(doc, (path,op)->Fail.fail("Unable to apply patch: " + op));
    Testing.print("patch = " + patch);
    Testing.print("doc = " + doc);
    
    assertThat(doc.getString("firstName")).isEqualTo("Jackie");
    assertThat(doc.getString("lastName")).isEqualTo("Jones");
    assertThat(Message.getId(doc)).isEqualTo(ENTITY_ID);
}
 
开发者ID:rhauch,项目名称:debezium-proto,代码行数:22,代码来源:PatchTest.java

示例4: shouldBuildAndApplyPatchToAddSimpleAndDocumentFieldsToEntity

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void shouldBuildAndApplyPatchToAddSimpleAndDocumentFieldsToEntity() {
    //Testing.Print.enable();
    
    Patch<EntityId> patch = Patch.edit(ENTITY_ID)
            .add("firstName", Value.create("Jackie"))
            .add("lastName", Value.create("Jones"))
            .add("address", Value.create(Document.create("street","123 Main","city","Springfield")))
            .end();
    assertThat(patch.isCreation()).isFalse();

    // Apply the patch ....
    Document doc = Document.create();
    Message.addId(doc, ENTITY_ID);
    patch.apply(doc, (path,op)->Fail.fail("Unable to apply patch: " + op));
    Testing.print("patch = " + patch);
    Testing.print("doc = " + doc);
    
    assertThat(Message.getId(doc)).isEqualTo(ENTITY_ID);
    assertThat(doc.getString("firstName")).isEqualTo("Jackie");
    assertThat(doc.getString("lastName")).isEqualTo("Jones");
    Document address = doc.getDocument("address");
    assertThat(address.getString("street")).isEqualTo("123 Main");
    assertThat(address.getString("city")).isEqualTo("Springfield");
}
 
开发者ID:rhauch,项目名称:debezium-proto,代码行数:26,代码来源:PatchTest.java

示例5: directDeleteProperty

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void directDeleteProperty() throws Exception {
    String methodName = "testDirectDeleteProperty";
    assertThat(db.getCollectionNames().contains(methodName)).isFalse();

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject();
    object.append("foo", new BasicDBObject("bar", "123"));
    db.getCollection(methodName).insert(object);
    String id = object.getObjectId("_id").toString();
    assertThat(db.getCollection(methodName).findOne(new BasicDBObject("_id", new ObjectId(id)))).isNotNull();

    // we should not be able to directly delete a child property
    try {
        client.delete(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/foo");
        Fail.fail("We should not be able to directly delete a property");
    } catch (ResourceNotFoundException e) {
        // expected
    }

    assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:23,代码来源:MongoDBResourceDeleteTest.java

示例6: deleteChildObject

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void deleteChildObject() throws Exception {
    String methodName = "testDeleteChildObject";
    assertThat(db.getCollectionNames().contains(methodName)).isFalse();

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject();
    object.append("foo", new BasicDBObject("bar", new BasicDBObject("ABC", 123)));
    db.getCollection(methodName).insert(object);
    String id = object.getObjectId("_id").toString();
    assertThat(db.getCollection(methodName).findOne(new BasicDBObject("_id", new ObjectId(id)))).isNotNull();

    // we should not be able to directly delete a child object
    try {
        client.delete(new RequestContext.Builder().returnFields(new DefaultReturnFields("bar(ABC(*))")).build(), "/testApp/" + BASEPATH + "/" + methodName
                + "/" + id + "/foo");
        Fail.fail("We should not be able to directly delete a child object");
    } catch (ResourceNotFoundException e) {
        // expected
    }

    assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:24,代码来源:MongoDBResourceDeleteTest.java

示例7: deleteChildProperty

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void deleteChildProperty() throws Exception {
    String methodName = "testDeleteChildProperty";
    assertThat(db.getCollectionNames().contains(methodName)).isFalse();

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject();
    object.append("foo", new BasicDBObject("bar", new BasicDBObject("ABC", 123)));
    db.getCollection(methodName).insert(object);
    String id = object.getObjectId("_id").toString();
    assertThat(db.getCollection(methodName).findOne(new BasicDBObject("_id", new ObjectId(id)))).isNotNull();

    // we should not be able to directly delete a child property
    try {
        client.delete(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/foo/bar");
        Fail.fail("We should not be able to directly delete a property on a child object");
    } catch (ResourceNotFoundException e) {
        // expected
    }

    assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:23,代码来源:MongoDBResourceDeleteTest.java

示例8: deleteGrandchildObject

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void deleteGrandchildObject() throws Exception {
    String methodName = "testDeleteGrandchildObject";
    assertThat(db.getCollectionNames().contains(methodName)).isFalse();

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject();
    object.append("foo", new BasicDBObject("bar", new BasicDBObject("ABC", new BasicDBObject("123", "XYZ"))));
    db.getCollection(methodName).insert(object);
    String id = object.getObjectId("_id").toString();
    assertThat(db.getCollection(methodName).findOne(new BasicDBObject("_id", new ObjectId(id)))).isNotNull();

    // we should not be able to directly delete a child object
    try {
        client.delete(new RequestContext.Builder().returnFields(new DefaultReturnFields("bar(ABC(*))")).build(), "/testApp/" + BASEPATH + "/" + methodName
                + "/" + id + "/foo");
        Fail.fail();
    } catch (ResourceNotFoundException e) {
        // expected
    }

    assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:24,代码来源:MongoDBResourceDeleteTest.java

示例9: getChildDirectly

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void getChildDirectly() throws Exception {
    String methodName = "testGetChildDirectly";
    assertThat(db.collectionExists(methodName)).isFalse();

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject();
    object.append("foo", "bar").append("abc", "123").append("obj", new BasicDBObject("foo2", "bar2"));
    object.append("child", new BasicDBObject("grandchild", new BasicDBObject("foo3", "bar3")));
    db.getCollection(methodName).insert(object);
    assertEquals(1, db.getCollection(methodName).getCount());
    String id = "ObjectId(\"" + object.getObjectId("_id").toString() + "\")";

    try {
        client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/child");
        Fail.fail();
    } catch (ResourceNotFoundException e) {
        // expected
    }
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:21,代码来源:MongoDBResourceReadTest.java

示例10: getCollection

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void getCollection() throws Exception {
    String methodName = "testGetCollection";
    assertThat(db.collectionExists(methodName)).isFalse();

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject("_id", "foobaz");

    BasicDBList list = new BasicDBList();
    list.add(1);
    list.add("A");
    list.add(new BasicDBObject("_id", "test123").append("foo", "bar"));
    object.append("array", list);

    db.getCollection(methodName).insert(object);
    assertEquals(1, db.getCollection(methodName).getCount());

    try {
        client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/foobaz/array");
        Fail.fail();
    } catch (ResourceNotFoundException e) {
        // expected
    }
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:25,代码来源:MongoDBResourceReadTest.java

示例11: getEmptyCollection

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void getEmptyCollection() throws Exception {
    String methodName = "testEmptyCollection";
    // check that the collection really is empty
    assertFalse(db.collectionExists(methodName));

    try {
        client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName);
        Fail.fail();
    } catch (ResourceNotFoundException e) {
        // expected
    }

    db.createCollection(methodName, new BasicDBObject());

    ResourceState result = client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName);

    // verify the result
    assertThat(result.id()).isEqualTo(methodName);
    assertThat(result.getProperty("type")).isEqualTo("collection");
    assertThat(result.members()).isEmpty();

    // check that the collection is still empty
    assertEquals(0, db.getCollection(methodName).getCount());
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:26,代码来源:MongoDBCollectionReadTest.java

示例12: getStorageCollectionsInvalidQueryString

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void getStorageCollectionsInvalidQueryString() throws Exception {
    DBCollection collection = db.getCollection("testQueryCollectionInvalid");
    if (collection != null) {
        collection.drop();
    }
    collection = db.createCollection("testQueryCollectionInvalid", new BasicDBObject("count", 0));

    // insert data records for the test
    setupPeopleData(collection);
    assertThat(collection.count()).isEqualTo(6);

    // This should return 2 items
    SimpleResourceParams resourceParams = new SimpleResourceParams();
    resourceParams.put("q", "{lastName,\"foo\"}");
    RequestContext requestContext = new RequestContext.Builder().returnFields(new DefaultReturnFields("*(*)")).resourceParams(resourceParams).build();

    try {
        client.read(requestContext, "/testApp/" + BASEPATH + "/testQueryCollectionInvalid");
        Fail.fail();
    } catch (NotAcceptableException iee) {
        // TODO fix me
        //assertThat(iee.message()).isEqualTo("Invalid JSON format for the 'query' parameter");
        //assertThat(iee.getCause().getClass().getName()).isEqualTo("com.mongodb.util.JSONParseException");
    }
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:27,代码来源:MongoDBCollectionReadTest.java

示例13: childDirectUpdate

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void childDirectUpdate() throws Exception {
    String methodName = "testChildDirectUpdate";
    assertThat(db.getCollection(methodName).getCount()).isEqualTo(0);

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject();
    object.append("foo", new BasicDBObject("bar", "baz"));
    db.getCollection(methodName).insert(object);
    assertEquals(1, db.getCollection(methodName).getCount());
    String id = "ObjectId(\"" + object.getObjectId("_id").toString() + "\")";

    // update the resource using the client.update method
    ResourceState resourceState = new DefaultResourceState();
    resourceState.putProperty("bar", 123);

    // should not be able to directly update a child object
    try {
        client.update(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/foo", resourceState);
        Fail.fail();
    } catch (CreateNotSupportedException e) {
        // expected
    }

    assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:27,代码来源:MongoDBResourceUpdateTest.java

示例14: grandchildDirectUpdate

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void grandchildDirectUpdate() throws Exception {
    String methodName = "testGrandChildDirectUpdate";
    assertThat(db.getCollection(methodName).getCount()).isEqualTo(0);

    // create the object using the mongo driver directly
    BasicDBObject object = new BasicDBObject();
    object.append("foo", new BasicDBObject("bar", new BasicDBObject("baz", "ABC")));
    db.getCollection(methodName).insert(object);
    assertEquals(1, db.getCollection(methodName).getCount());
    String id = "ObjectId(\"" + object.getObjectId("_id").toString() + "\")";

    // update the resource using the client.update method
    ResourceState resourceState = new DefaultResourceState();
    resourceState.putProperty("baz", "XYZ");

    try {
        client.update(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/foo/bar", resourceState);
        Fail.fail();
    } catch (ResourceNotFoundException e) {
        // expected
    }

    assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:26,代码来源:MongoDBResourceUpdateTest.java

示例15: invalidType

import org.fest.assertions.Fail; //导入依赖的package包/类
@Test
public void invalidType() throws Exception {
    ResourceState config = new DefaultResourceState();
    config.putProperty("db", "testInvalidTypeDB");
    config.putProperty("servers", new ArrayList());

    ResourceState configReadPref = new DefaultResourceState();
    configReadPref.putProperty(ReadPreferenceState.TYPE, "foobar");
    config.putProperty(ReadPreferenceState.ID, configReadPref);

    try {
        setUpSystem(config);
        Fail.fail();
    } catch (InitializationException e) {
        //expected
    }
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:18,代码来源:MongoConfigReadPreferenceTest.java


注:本文中的org.fest.assertions.Fail类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。