@Test
public void testFindDataObjectsWithDescribe() {

    DXRecord.newRecord().setProject(testProject).setName("record1")
            .putProperty("sampleId", "1234").build();
    DXFile.newFile().setProject(testProject).setName("file1").putProperty("sampleId", "2345")
            .build();
    DXApplet.newApplet().setProject(testProject).setName("applet1")
            .setRunSpecification(RunSpecification.newRunSpec("bash", "", "Ubuntu", "14.04").build()).build();
    DXWorkflow.newWorkflow().setProject(testProject).setName("workflow1").build();
    DXRecord recordResult =
            Iterables.getOnlyElement(DXSearch.findDataObjects().withClassRecord()
                    .inProject(testProject).nameMatchesExactly("record1")
                    .includeDescribeOutput(DXDataObject.DescribeOptions.get().withProperties())
                    .execute().asList());
    Assert.assertEquals(recordResult.getCachedDescribe().getName(), "record1");
    // Called includeDescribeOutput with properties: true so properties should be returned
    Assert.assertEquals(recordResult.getCachedDescribe().getProperties().get("sampleId"),
            "1234");
    recordResult =
            Iterables.getOnlyElement(DXSearch.findDataObjects().withClassRecord()
                    .inProject(testProject).nameMatchesExactly("record1")
                    .includeDescribeOutput().execute().asList());
    Assert.assertEquals(recordResult.getCachedDescribe().getName(), "record1");
    // Called includeDescribeOutput with default settings so properties should NOT be returned
    try {
        recordResult.getCachedDescribe().getProperties();
        Assert.fail("Expected IllegalStateException to be thrown because properties should not have been returned");
    } catch (IllegalStateException e) {
        // Expected
    }
    Assert.assertEquals(
            Iterables
                    .getOnlyElement(
                            DXSearch.findDataObjects().inProject(testProject)
                                    .nameMatchesExactly("file1").includeDescribeOutput()
                                    .execute().asList()).getCachedDescribe().getName(), "file1");
    Assert.assertEquals(
            Iterables
                    .getOnlyElement(
                            DXSearch.findDataObjects().inProject(testProject)
                                    .nameMatchesExactly("applet1").includeDescribeOutput()
                                    .execute().asList()).getCachedDescribe().getName(),
            "applet1");
    Assert.assertEquals(
            Iterables
                    .getOnlyElement(
                            DXSearch.findDataObjects().inProject(testProject)
                                    .nameMatchesExactly("workflow1").includeDescribeOutput()
                                    .execute().asList()).getCachedDescribe().getName(),
            "workflow1");
    DXRecord findWithoutDescribe =
            Iterables.getOnlyElement(DXSearch.findDataObjects().inProject(testProject)
                    .nameMatchesExactly("record1").withClassRecord().execute().asList());
    try {
        findWithoutDescribe.getCachedDescribe();
        Assert.fail("Expected IllegalStateException to be thrown");
    } catch (IllegalStateException e) {
        // Expected
    }
}