Example usage for org.apache.commons.httpclient HttpStatus SC_NOT_FOUND

List of usage examples for org.apache.commons.httpclient HttpStatus SC_NOT_FOUND

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpStatus SC_NOT_FOUND.

Prototype

int SC_NOT_FOUND

To view the source code for org.apache.commons.httpclient HttpStatus SC_NOT_FOUND.

Click Source Link

Document

<tt>404 Not Found</tt> (HTTP/1.0 - RFC 1945)

Usage

From source file:org.alfresco.rest.api.tests.TestSiteMembershipRequests.java

@Test
public void testMixedCase() throws Exception {
    final List<SiteMembershipRequest> expectedSiteMembershipRequests = new ArrayList<SiteMembershipRequest>();

    {/*ww  w .  j a v  a2s  . co  m*/
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person15Id));

        // moderated site
        String siteId = person1MixedCaseModeratedSites.get(0).getSiteId().toLowerCase();

        SiteMembershipRequest siteMembershipRequest = new SiteMembershipRequest();
        siteMembershipRequest.setId(siteId); // lower case to test mixed case
        siteMembershipRequest.setMessage("Please can I join your site?");
        final SiteMembershipRequest moderatedSiteResponse = siteMembershipRequestsProxy
                .createSiteMembershipRequest("-me-", siteMembershipRequest);
        expectedSiteMembershipRequests.add(moderatedSiteResponse);
        Collections.sort(expectedSiteMembershipRequests);
        siteMembershipRequest.expected(moderatedSiteResponse);

        int skipCount = 0;
        int maxItems = 2;
        Paging paging = getPaging(skipCount, maxItems, expectedSiteMembershipRequests.size(),
                expectedSiteMembershipRequests.size());
        ListResponse<SiteMembershipRequest> resp = siteMembershipRequestsProxy
                .getSiteMembershipRequests(person15Id, createParams(paging, null));
        checkList(expectedSiteMembershipRequests.subList(skipCount,
                skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);

        SiteMembershipRequest ret = siteMembershipRequestsProxy.getSiteMembershipRequest(person15Id, siteId);
        siteMembershipRequest.expected(ret);

        siteMembershipRequestsProxy.cancelSiteMembershipRequest(person15Id, ret.getId());

        try {
            siteMembershipRequestsProxy.getSiteMembershipRequest(person15Id, siteId);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
        }
    }
}

From source file:org.alfresco.rest.api.tests.TestTags.java

@Test
public void testTags() throws Exception {
    Iterator<TestNetwork> networksIt = getTestFixture().getNetworksIt();
    assertTrue(networksIt.hasNext());// w  w w.  jav  a  2 s. c o  m
    final TestNetwork network1 = networksIt.next();
    assertTrue(networksIt.hasNext());
    final TestNetwork network2 = networksIt.next();

    final List<TestPerson> people = new ArrayList<TestPerson>(3);

    // create users and some preferences
    TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>() {
        @Override
        public Void doWork() throws Exception {
            TestPerson person = network1.createUser();
            people.add(person);
            person = network1.createUser();
            people.add(person);
            return null;
        }
    }, network1.getId());

    TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>() {
        @Override
        public Void doWork() throws Exception {
            TestPerson person = network2.createUser();
            people.add(person);
            return null;
        }
    }, network2.getId());

    final TestPerson person1 = people.get(0);
    final TestPerson person2 = people.get(1);
    final TestPerson person3 = people.get(2);

    final List<NodeRef> nodes = new ArrayList<NodeRef>();
    final List<TestSite> sites = new ArrayList<TestSite>();

    // Create site
    TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() {
        @Override
        public Void doWork() throws Exception {
            TestSite site = network1.createSite(SiteVisibility.PRIVATE);
            sites.add(site);

            NodeRef nodeRef = repoService.createDocument(site.getContainerNodeRef("documentLibrary"),
                    "Test Doc", "Test Content");
            nodes.add(nodeRef);

            nodeRef = repoService.createDocument(site.getContainerNodeRef("documentLibrary"), "Test Doc 1",
                    "Test Content 1");
            nodes.add(nodeRef);

            return null;
        }
    }, person1.getId(), network1.getId());

    final NodeRef nodeRef1 = nodes.get(0);
    final NodeRef nodeRef2 = nodes.get(1);

    Nodes nodesProxy = publicApiClient.nodes();
    Comments commentsProxy = publicApiClient.comments();
    Tags tagsProxy = publicApiClient.tags();

    final List<Tag> tags = new ArrayList<Tag>();
    tags.add(new Tag("tag 1"));
    tags.add(new Tag("tag 9"));
    tags.add(new Tag("other tag 3"));
    tags.add(new Tag("my tag 1"));
    tags.add(new Tag("tag 5"));

    // try to add a tag to a comment
    try {
        Comment comment = new Comment("Test Comment", "Test Comment");
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Comment newComment = commentsProxy.createNodeComment(nodeRef1.getId(), comment);
        Tag tag = new Tag("testTag");
        nodesProxy.createNodeTag(newComment.getId(), tag);
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    // try to add a tag to a tag
    try {
        Tag tag = new Tag("testTag");
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Tag newTag = nodesProxy.createNodeTag(nodeRef1.getId(), tag);
        nodesProxy.createNodeTag(newTag.getId(), tag);
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    // Test Case cloud-2221
    // Test Case cloud-2222
    // multi-byte characters, special characters, create and update tags
    {
        Tag[] multiByteTags = new Tag[] { new Tag("\u67e5\u770b\u5168\u90e8"),
                new Tag("\u67e5\u770b\u5168\u91e8"), new Tag("%^&%&$^@") };

        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));

        // first, create tags
        Map<String, Tag> createdTags = new HashMap<String, Tag>();
        for (Tag tag : multiByteTags) {
            Tag ret = nodesProxy.createNodeTag(nodeRef2.getId(), tag);
            createdTags.put(ret.getId(), ret);
        }

        int skipCount = 0;
        int maxItems = Integer.MAX_VALUE;
        Paging paging = getPaging(skipCount, maxItems);
        ListResponse<Tag> resp = nodesProxy.getNodeTags(nodeRef2.getId(), createParams(paging, null));
        List<Tag> retTags = resp.getList();
        assertEquals(createdTags.size(), retTags.size());
        for (Tag tag : retTags) {
            String tagId = tag.getId();
            Tag expectedTag = createdTags.get(tagId);
            expectedTag.expected(tag);
        }

        // special characters and update tags
        //         {
        //            Tag[] specialCharacterTags = new Tag[]
        //            {
        //                  new Tag("\u67e5\u770b\u5168\u90e8"),
        //                  new Tag("\u67e5\u770b\u5168\u91e8")
        //            };
        //            
        //            createdTags = new HashMap<String, Tag>();
        //            for(Tag tag : specialCharacterTags)
        //            {
        //               Tag ret = nodesProxy.createNodeTag(nodeRef2.getId(), tag);
        //               createdTags.put(ret.getId(), ret);
        //            }
        //            
        //            
        //            Tag tag = new Tag("%^&%&$^@");
        //            Tag ret = nodesProxy.createNodeTag(nodeRef2.getId(), tag);
        //            createdTags.put(ret.getId(), ret);
        //         }

        // update tags

        try {
            // update with an empty tag i.e. "" -> bad request
            Tag tag = new Tag("");
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.createNodeTag(nodeRef2.getId(), tag);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }

        List<Tag> tagUpdates = new ArrayList<Tag>(createdTags.values());
        tagUpdates.get(0).setTag("\u4e00\u4e01\u4e02\u4e10");
        tagUpdates.get(1).setTag("\u4e00\u4e01\u4e12\u4e11");
        tagUpdates.get(2).setTag("\u4e00\u4e01\u4e12\u4e12");
        Map<String, Tag> updatedTags = new HashMap<String, Tag>();
        for (Tag tag : tagUpdates) {
            Tag ret = tagsProxy.update(tag);
            assertNotNull(ret.getId());
            assertNotNull(ret.getTag());
            //            tag.expected(ret); disabled because tag id changes
            updatedTags.put(ret.getId(), ret);
        }

        // get updated tags
        List<Tag> expectedNodeTags = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<Tag>>() {
            @Override
            public List<Tag> doWork() throws Exception {
                List<Tag> tags = repoService.getTags(nodeRef2);
                return tags;
            }
        }, person1.getId(), network1.getId());

        skipCount = 0;
        maxItems = tagUpdates.size();
        paging = getPaging(skipCount, maxItems, tagUpdates.size(), tagUpdates.size());
        resp = nodesProxy.getNodeTags(nodeRef2.getId(), createParams(paging, null));
        checkList(expectedNodeTags.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                paging.getExpectedPaging(), resp);
    }

    {
        List<Tag> createdTags = new ArrayList<Tag>();

        // Test Case cloud-1975
        for (Tag tag : tags) {
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            Tag ret = nodesProxy.createNodeTag(nodeRef1.getId(), tag);
            assertEquals(tag.getTag(), ret.getTag());
            assertNotNull(ret.getId());
            createdTags.add(ret);
        }

        // update tag, empty string
        try {
            Tag tag = new Tag(createdTags.get(0).getId(), "");
            tagsProxy.update(tag);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }

        // invalid node id
        try {
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.createNodeTag(GUID.generate(), tags.get(0));
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
        }

        // Test Case cloud-1973
        // Test Case cloud-2208
        // Test Case cloud-2219
        // check that the tags are there in the node tags, test paging
        List<Tag> expectedNodeTags = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<Tag>>() {
            @Override
            public List<Tag> doWork() throws Exception {
                List<Tag> tags = repoService.getTags(nodeRef1);
                return tags;
            }
        }, person1.getId(), network1.getId());

        {
            int skipCount = 0;
            int maxItems = 2;
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            Paging paging = getPaging(skipCount, maxItems, expectedNodeTags.size(), expectedNodeTags.size());
            ListResponse<Tag> resp = nodesProxy.getNodeTags(nodeRef1.getId(), createParams(paging, null));
            checkList(expectedNodeTags.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                    paging.getExpectedPaging(), resp);
        }

        {
            int skipCount = 2;
            int maxItems = Integer.MAX_VALUE;
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            Paging paging = getPaging(skipCount, maxItems, expectedNodeTags.size(), expectedNodeTags.size());
            ListResponse<Tag> resp = nodesProxy.getNodeTags(nodeRef1.getId(), createParams(paging, null));
            checkList(expectedNodeTags.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                    paging.getExpectedPaging(), resp);
        }

        // invalid node
        try {
            int skipCount = 0;
            int maxItems = 2;
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            Paging paging = getPaging(skipCount, maxItems, expectedNodeTags.size(), expectedNodeTags.size());
            ListResponse<Tag> allTags = nodesProxy.getNodeTags("invalidNode", createParams(paging, null));
            checkList(expectedNodeTags.subList(skipCount, paging.getExpectedPaging().getCount()),
                    paging.getExpectedPaging(), allTags);
            fail("");
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
        }

        // user from another account - 403
        try {
            int skipCount = 0;
            int maxItems = 2;
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person3.getId()));
            Paging expectedPaging = getPaging(skipCount, maxItems, expectedNodeTags.size(),
                    expectedNodeTags.size());
            nodesProxy.getNodeTags(nodeRef1.getId(), createParams(expectedPaging, null));
            fail("");
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_UNAUTHORIZED, e.getHttpResponse().getStatusCode());
        }

        // another user from the same account
        try {
            int skipCount = 0;
            int maxItems = 2;
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2.getId()));
            Paging paging = getPaging(skipCount, maxItems, expectedNodeTags.size(), expectedNodeTags.size());
            ListResponse<Tag> resp = nodesProxy.getNodeTags(nodeRef1.getId(), createParams(paging, null));
            checkList(expectedNodeTags.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                    paging.getExpectedPaging(), resp);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_FORBIDDEN, e.getHttpResponse().getStatusCode());
        }

        // Test Case cloud-1519
        // Test Case cloud-2206
        // Test Case cloud-2218
        // check that the tags are there in the network tags, test paging
        // TODO for user from another network who is invited to this network
        List<Tag> expectedNetworkTags = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<Tag>>() {
            @Override
            public List<Tag> doWork() throws Exception {
                List<Tag> tags = repoService.getTags();
                return tags;
            }
        }, person1.getId(), network1.getId());

        {
            int skipCount = 0;
            int maxItems = 2;
            Paging paging = getPaging(skipCount, maxItems, expectedNetworkTags.size(), null);
            ListResponse<Tag> allTags = tagsProxy.getTags(createParams(paging, null));
            checkList(expectedNetworkTags.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                    paging.getExpectedPaging(), allTags);
        }

        {
            int skipCount = 2;
            int maxItems = Integer.MAX_VALUE;
            Paging paging = getPaging(skipCount, maxItems, expectedNetworkTags.size(), null);
            ListResponse<Tag> allTags = tagsProxy.getTags(createParams(paging, null));
            checkList(expectedNetworkTags.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                    paging.getExpectedPaging(), allTags);
        }
    }

    {
        // Try a create with the same tag value
        Tag tag = tags.get(0);
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        nodesProxy.createNodeTag(nodeRef1.getId(), tag);
    }

    try {
        // Invalid node id
        Tag tag = tags.get(0);
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        nodesProxy.createNodeTag(GUID.generate(), tag);
        fail("");
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
    }

    // Test Case cloud-2183
    // update tags
    {
        // get a network tag
        int skipCount = 0;
        int maxItems = 2;
        Paging paging = getPaging(skipCount, maxItems);
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        ListResponse<Tag> allTags = tagsProxy.getTags(createParams(paging, null));
        assertTrue(allTags.getList().size() > 0);

        // and update it
        Tag tag = allTags.getList().get(0);
        String newTagValue = GUID.generate();
        Tag newTag = new Tag(tag.getId(), newTagValue);
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Tag ret = tagsProxy.update(newTag);
        assertEquals(newTagValue, ret.getTag());
        //         assertNotEquals(tag.getId, ret.getId()); // disabled due to CLOUD-628
    }

    // update invalid/unknown tag id
    try {
        Tag unknownTag = new Tag(GUID.generate(), GUID.generate());
        tagsProxy.update(unknownTag);
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
    }

    // Test Case cloud-1972
    // Test Case cloud-1974
    // not allowed methods
    {
        List<Tag> networkTags = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<Tag>>() {
            @Override
            public List<Tag> doWork() throws Exception {
                List<Tag> tags = repoService.getTags();
                return tags;
            }
        }, person1.getId(), network1.getId());
        assertTrue(networkTags.size() > 0);

        try {
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.update("nodes", nodeRef1.getId(), "tags", null, null, "Unable to PUT node tags");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        try {
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.remove("nodes", nodeRef1.getId(), "tags", null, "Unable to DELETE node tags");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        try {
            Tag tag = networkTags.get(0);

            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.update("nodes", nodeRef1.getId(), "tags", tag.getId(), null, "Unable to PUT node tag");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        try {
            Tag tag = networkTags.get(0);

            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.create("tags", null, null, null, tag.toJSON().toString(), "Unable to POST to tags");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        try {
            Tag tag = networkTags.get(0);

            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.update("tags", null, null, null, tag.toJSON().toString(), "Unable to PUT tags");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        try {
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.remove("tags", null, null, null, "Unable to DELETE tags");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        try {
            Tag tag = networkTags.get(0);

            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.create("tags", tag.getId(), null, null, tag.toJSON().toString(),
                    "Unable to POST to a tag");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        try {
            Tag tag = networkTags.get(0);

            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.remove("tags", tag.getId(), null, null, "Unable to DELETE a tag");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }

        // delete node tag
        {
            Tag tag = networkTags.get(0);

            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.removeNodeTag(nodeRef1.getId(), tag.getId());

            // check that the tag is gone
            ListResponse<Tag> resp = nodesProxy.getNodeTags(nodeRef1.getId(),
                    createParams(getPaging(0, Integer.MAX_VALUE), null));
            List<Tag> nodeTags = resp.getList();
            assertTrue(!nodeTags.contains(tag));
        }

        try {
            Tag tag = networkTags.get(0);

            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            nodesProxy.getSingle("nodes", nodeRef1.getId(), "tags", tag.getId(), "Unable to GET node tag");
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
        }
    }
}

From source file:org.alfresco.rest.api.tests.TestUserPreferences.java

@Test
public void testUserPreferences() throws Exception {
    Iterator<TestNetwork> networksIt = getTestFixture().getNetworksIt();
    assertTrue(networksIt.hasNext());//from w  w  w  .  j  av  a 2  s  .  c o  m
    final TestNetwork network1 = networksIt.next();
    assertTrue(networksIt.hasNext());
    final TestNetwork network2 = networksIt.next();

    final List<TestPerson> people = new ArrayList<TestPerson>(3);

    // create users and some preferences
    TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>() {
        @Override
        public Void doWork() throws Exception {
            TestPerson person = network1.createUser();
            people.add(person);
            person = network1.createUser();
            people.add(person);
            return null;
        }
    }, network1.getId());

    TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>() {
        @Override
        public Void doWork() throws Exception {
            TestPerson person = network2.createUser();
            people.add(person);
            return null;
        }
    }, network2.getId());

    final TestPerson person1 = people.get(0);
    final TestPerson person2 = people.get(1);
    final TestPerson person3 = people.get(2);

    final List<Preference> expectedPreferences = new ArrayList<Preference>();
    expectedPreferences
            .add(new Preference("org.alfresco.share.documentList.testPreference2", String.valueOf(true)));
    expectedPreferences
            .add(new Preference("org.alfresco.share.documentList.testPreference1", String.valueOf(true)));
    expectedPreferences
            .add(new Preference("org.alfresco.share.documentList.sortAscending", String.valueOf(true)));
    expectedPreferences
            .add(new Preference("org.alfresco.share.documentList.testPreference3", String.valueOf(true)));
    // new preference name for issue REPO-855
    expectedPreferences.add(new Preference(
            "org.alfresco.ext.folders.favourites.workspace://SpacesStore/4e3d0779-388a-4b94-91e1-eab588a7da3d.createdAt",
            String.valueOf(true)));

    TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() {
        @Override
        public Void doWork() throws Exception {
            for (Preference pref : expectedPreferences) {
                // TODO add preferences thru api
                repoService.addPreference(person1.getId(), pref.getId(), pref.getValue());
            }

            return null;
        }
    }, person1.getId(), network1.getId());

    Collections.sort(expectedPreferences);

    People peopleProxy = publicApiClient.people();

    // GET preferences
    // Test case: cloud-1492

    // unknown user
    try {
        int skipCount = 0;
        int maxItems = 2;
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Paging paging = getPaging(skipCount, maxItems, expectedPreferences.size(), expectedPreferences.size());
        peopleProxy.getPreferences(GUID.generate(), createParams(paging, null));

        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
    }

    // test paging
    {
        int skipCount = 0;
        int maxItems = 2;
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Paging paging = getPaging(skipCount, maxItems, expectedPreferences.size(), expectedPreferences.size());
        ListResponse<Preference> resp = peopleProxy.getPreferences(person1.getId(), createParams(paging, null));
        checkList(expectedPreferences.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                paging.getExpectedPaging(), resp);
    }

    {
        int skipCount = 2;
        int maxItems = 10;
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Paging paging = getPaging(skipCount, maxItems, expectedPreferences.size(), expectedPreferences.size());
        ListResponse<Preference> resp = peopleProxy.getPreferences(person1.getId(), createParams(paging, null));
        checkList(expectedPreferences.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                paging.getExpectedPaging(), resp);
    }

    // "-me-" user
    {
        int skipCount = 0;
        int maxItems = 2;
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Paging paging = getPaging(skipCount, maxItems, expectedPreferences.size(), expectedPreferences.size());
        ListResponse<Preference> resp = peopleProxy.getPreferences(org.alfresco.rest.api.People.DEFAULT_USER,
                createParams(paging, null));
        checkList(expectedPreferences.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()),
                paging.getExpectedPaging(), resp);
    }

    // invalid user - 404
    try {
        int skipCount = 2;
        int maxItems = 10;
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Paging paging = getPaging(skipCount, maxItems, expectedPreferences.size(), expectedPreferences.size());
        peopleProxy.getPreferences("invalid.user", createParams(paging, null));
        fail("");
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
    }

    // user from another account - 401
    try {
        int skipCount = 0;
        int maxItems = 2;
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person3.getId()));
        Paging paging = getPaging(skipCount, maxItems, expectedPreferences.size(), expectedPreferences.size());
        //           ListResponse<Preference> resp = peopleProxy.getPreferences(person1.getId(), createParams(paging, null));
        //           checkList(expectedPreferences.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
        peopleProxy.getPreferences(person1.getId(), createParams(paging, null));
        fail();
    } catch (PublicApiException e) {
        assertEquals(e.getHttpResponse().getStatusCode(), HttpStatus.SC_UNAUTHORIZED);
    }

    // another user from the same account - 403
    try {
        int skipCount = 0;
        int maxItems = 2;
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2.getId()));
        Paging paging = getPaging(skipCount, maxItems, expectedPreferences.size(), expectedPreferences.size());
        peopleProxy.getPreferences(person1.getId(), createParams(paging, null));
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_FORBIDDEN, e.getHttpResponse().getStatusCode());
    }

    // get a single preference
    // Test Case: cloud-1493

    {
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        Preference pref = expectedPreferences.get(0);
        Preference ret = peopleProxy.getPreference(person1.getId(), pref.getId());
        pref.expected(ret);
    }

    // unknown person id
    try {
        Preference pref = expectedPreferences.get(0);
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2.getId()));
        peopleProxy.getPreference(GUID.generate(), pref.getId());
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
    }

    // unknown preference id
    try {
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        peopleProxy.getPreference(person1.getId(), GUID.generate());
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
    }

    // Invalid methods
    // Test case: cloud-1968
    try {
        Preference pref = expectedPreferences.get(0);

        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        peopleProxy.create("people", person1.getId(), "preferences", pref.getId(), pref.toJSON().toString(),
                "Unable to POST to a preference");
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    try {
        Preference pref = expectedPreferences.get(0);

        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        peopleProxy.update("people", person1.getId(), "preferences", pref.getId(), pref.toJSON().toString(),
                "Unable to PUT a preference");
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    try {
        Preference pref = expectedPreferences.get(0);

        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        peopleProxy.remove("people", person1.getId(), "preferences", pref.getId(),
                "Unable to DELETE a preference");
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    try {
        Preference pref = expectedPreferences.get(0);

        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        peopleProxy.create("people", person1.getId(), "preferences", null, pref.toJSON().toString(),
                "Unable to POST to preferences");
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    try {
        Preference pref = expectedPreferences.get(0);

        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        peopleProxy.update("people", person1.getId(), "preferences", null, pref.toJSON().toString(),
                "Unable to PUT preferences");
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    try {
        publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
        peopleProxy.remove("people", person1.getId(), "preferences", null, "Unable to DELETE preferences");
        fail();
    } catch (PublicApiException e) {
        assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
    }

    {
        // REPO-1061, REPO-890
        try {
            String skipCount = "a";
            String maxItems = "hi";
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("skipCount", skipCount);
            params.put("maxItems", maxItems);
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            peopleProxy.getPreferences(person1.getId(), params);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }

        try {
            String skipCount = "a";
            String maxItems = "null";
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("skipCount", skipCount);
            params.put("maxItems", maxItems);
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            peopleProxy.getPreferences(person1.getId(), params);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }

        try {
            String maxItems = "Red";
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("maxItems", maxItems);
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            peopleProxy.getPreferences(person1.getId(), params);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }

        try {
            String skipCount = "yuck";
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("skipCount", skipCount);
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            peopleProxy.getPreferences(person1.getId(), params);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }

        try {
            String skipCount = "-1";
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("skipCount", skipCount);
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            peopleProxy.getPreferences(person1.getId(), params);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }

        try {
            String maxItems = "0";
            HashMap<String, String> params = new HashMap<String, String>();
            params.put("maxItems", maxItems);
            publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
            peopleProxy.getPreferences(person1.getId(), params);
            fail();
        } catch (PublicApiException e) {
            assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
        }
    }
}

From source file:org.apache.ambari.funtest.server.tests.DeleteServiceTest.java

/**
 * Set up a test cluster with a service, a host and a few components.
 * Attempt to delete the service. Verify the state of the DB.
 *
 * @throws Exception//from w  ww  .  java 2 s. c  o  m
 */
@Test
public void testDeleteService() throws Exception {
    String clusterName = "c1";
    String serviceName = "HDFS";
    ConnectionParams params = new ConnectionParams();

    params.setServerName("localhost");
    params.setServerApiPort(serverPort);
    params.setServerAgentPort(serverAgentPort);
    params.setUserName("admin");
    params.setPassword("admin");

    ClusterUtils clusterUtils = injector.getInstance(ClusterUtils.class);
    clusterUtils.createSampleCluster(params);

    /**
     * Verify the status of the service
     */
    JsonElement jsonResponse = RestApiUtils
            .executeRequest(new GetServiceWebRequest(params, clusterName, serviceName));
    assertTrue(!jsonResponse.isJsonNull());
    JsonObject jsonServiceInfoObj = jsonResponse.getAsJsonObject().get("ServiceInfo").getAsJsonObject();
    String cluster_name = jsonServiceInfoObj.get("cluster_name").getAsString();
    assertEquals(cluster_name, clusterName);

    String service_name = jsonServiceInfoObj.get("service_name").getAsString();
    assertEquals(service_name, serviceName);

    /**
     * Check the following:
     * ClusterServiceDAO
     * ServiceDesiredStateDAO
     * ServiceComponentDesiredStateDAO
     * HostComponentStateDAO
     * HostComponentDesiredStateDAO
     */

    /**
     * Stop the service
     */

    jsonResponse = RestApiUtils.executeRequest(new StopServiceWebRequest(params, clusterName, serviceName));

    /**
     * clusterservice table
     */
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    List<ClusterServiceEntity> clusterServiceEntities = clusterServiceDAO.findAll();
    assertEquals(clusterServiceEntities.size(), 1); // Only one service in the sample cluster (HDFS)
    assertEquals(clusterServiceEntities.get(0).getServiceName(), serviceName); // Verify the only service name

    ClusterServiceEntity clusterServiceEntity = clusterServiceEntities.get(0);
    long clusterId = clusterServiceEntity.getClusterId();

    /**
     * servicedesiredstate table
     */
    ServiceDesiredStateDAO serviceDesiredStateDAO = injector.getInstance(ServiceDesiredStateDAO.class);
    List<ServiceDesiredStateEntity> serviceDesiredStateEntities = serviceDesiredStateDAO.findAll();
    assertEquals(serviceDesiredStateEntities.size(), 1);
    ServiceDesiredStateEntity serviceDesiredStateEntity = serviceDesiredStateEntities.get(0);
    assertEquals(serviceDesiredStateEntity.getServiceName(), serviceName);
    assertEquals(serviceDesiredStateEntity.getDesiredState(), State.INSTALLED);

    /**
     * servicecomponentdesiredstate table
     */
    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector
            .getInstance(ServiceComponentDesiredStateDAO.class);
    List<ServiceComponentDesiredStateEntity> serviceComponentDesiredStateEntities = serviceComponentDesiredStateDAO
            .findAll();
    assertEquals(serviceComponentDesiredStateEntities.size(), 3); // NAMENODE, SECONDARY_NAMENODE, DATANODE.
    for (ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity : serviceComponentDesiredStateEntities) {
        assertEquals(serviceComponentDesiredStateEntity.getDesiredState(), State.INSTALLED);
    }

    /**
     * hostcomponentstate table
     */
    HostComponentStateDAO hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
    List<HostComponentStateEntity> hostComponentStateEntities = hostComponentStateDAO.findAll();
    assertEquals(hostComponentStateEntities.size(), 3);

    /**
     * hostcomponentdesiredstate table
     */
    HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector
            .getInstance(HostComponentDesiredStateDAO.class);
    List<HostComponentDesiredStateEntity> hostComponentDesiredStateEntities = hostComponentDesiredStateDAO
            .findAll();
    assertEquals(hostComponentDesiredStateEntities.size(), 3);

    /**
     * Delete the service
     */
    jsonResponse = RestApiUtils.executeRequest(new DeleteServiceWebRequest(params, clusterName, serviceName));

    WebResponse webResponse = new GetServiceWebRequest(params, clusterName, serviceName).getResponse();
    assertEquals(webResponse.getStatusCode(), HttpStatus.SC_NOT_FOUND);

    /**
     * ClusterServiceDAO - the service entry should have been removed.
     */
    clusterServiceEntity = clusterServiceDAO.findByClusterAndServiceNames(clusterName, serviceName);
    assertTrue(clusterServiceEntity == null);

    /**
     * ServiceDesiredStateDAO - the service entry should have been removed.
     */
    ServiceDesiredStateEntityPK serviceDesiredStateEntityPK = injector
            .getInstance(ServiceDesiredStateEntityPK.class);
    serviceDesiredStateEntityPK.setClusterId(clusterId);
    serviceDesiredStateEntityPK.setServiceName(serviceName);
    serviceDesiredStateEntity = serviceDesiredStateDAO.findByPK(serviceDesiredStateEntityPK);
    assertTrue(serviceDesiredStateEntity == null);

    /**
     * ServiceComponentDesiredStateDAO
     */
    ServiceComponentDesiredStateEntityPK serviceComponentDesiredStateEntityPK = injector
            .getInstance(ServiceComponentDesiredStateEntityPK.class);
    ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO
            .findByPK(serviceComponentDesiredStateEntityPK);
    assertTrue(serviceComponentDesiredStateEntity == null);

    /**
     * HostComponentStateDAO
     */
    hostComponentStateEntities = hostComponentStateDAO.findByService(serviceName);
    assertEquals(hostComponentStateEntities.size(), 0);

    /**
     * HostComponentDesiredStateDAO
     */
    hostComponentDesiredStateEntities = hostComponentDesiredStateDAO.findAll();
    assertEquals(hostComponentDesiredStateEntities.size(), 0);

    jsonResponse = RestApiUtils.executeRequest(new DeleteClusterWebRequest(params, clusterName));

    LOG.info(jsonResponse);
}

From source file:org.apache.ambari.view.slider.rest.client.BaseHttpClient.java

@SuppressWarnings("deprecation")
public JsonElement doGetJson(String url, String path) throws HttpException, IOException {
    GetMethod get = new GetMethod(url + path);
    if (isNeedsAuthentication()) {
        get.setDoAuthentication(true);//  w w w. j av a2s. com
    }
    int executeMethod = getHttpClient().executeMethod(get);
    switch (executeMethod) {
    case HttpStatus.SC_OK:
        JsonElement jsonElement = new JsonParser()
                .parse(new JsonReader(new InputStreamReader(get.getResponseBodyAsStream())));
        return jsonElement;
    case HttpStatus.SC_NOT_FOUND:
        return null;
    default:
        HttpException httpException = new HttpException(get.getResponseBodyAsString());
        httpException.setReason(HttpStatus.getStatusText(executeMethod));
        httpException.setReasonCode(executeMethod);
        throw httpException;
    }
}

From source file:org.apache.clerezza.integrationtest.web.performance.Get404.java

@Override
public void run() {

    try {// w  w  w.  java 2 s  .c  o  m
        URL serverURL = new URL(testSubjectUriPrefix + "/foobar");
        HttpClient client = new HttpClient();

        client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
        HttpMethod method = new GetMethod(serverURL.toString());
        method.setRequestHeader("Accept", "*/*");
        method.setDoAuthentication(true);

        try {
            int responseCode = client.executeMethod(method);

            if (responseCode != HttpStatus.SC_NOT_FOUND) {
                throw new RuntimeException("Get404: unexpected " + "response code: " + responseCode);
            }
        } finally {
            method.releaseConnection();
        }
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.apache.cocoon.components.source.impl.WebDAVSource.java

/**
 * Initialize the SWCL WebdavResource.//  w w  w . ja  v  a 2s . co m
 * <p>
 * The action argument specifies a set of properties to load during initialization.
 * Its value is one of WebdavResource.NOACTION, WebdavResource.NAME,
 * WebdavResource.BASIC, WebdavResource.DEFAULT, WebdavResource.ALL.
 * Similarly the depth argument specifies the depth header of the PROPFIND
 * method that is executed upon initialization.
 * </p>
 * <p>
 * The different methods of this Source implementation call this method to
 * initialize the resource using their minimal action and depth requirements.
 * For instance the WebDAVSource.getMimeType() method requires WebdavResource.BASIC
 * properties and a search depth of 0 is sufficient.
 * </p>
 * <p>
 * However it may be that a later call (eg. WebDAVSource.getChildren()) requires more
 * information. In that case the WebdavResource would have to make another call to the Server.
 * It would be more efficient if previous initialization had been done using depth 1 instead.
 * In order give the user more control over this the WebDAVSource can be passed a minimal
 * action and depth using cocoon:webdav-depth and cocoon:webdav-action query string parameters.
 * By default the mimimum action is WebdavResource.BASIC (which loads all the following basic
 * webdav properties: DAV:displayname, DAV:getcontentlength, DAV:getcontenttype DAV:resourcetype,
 * DAV:getlastmodified and DAV:lockdiscovery). The default minimum depth is 1.
 * </p>
 *
 * @param action  the set of propterties the WebdavResource should load.
 * @param depth  the webdav depth.
 * @throws SourceException
 * @throws SourceNotFoundException
 */
private void initResource(int action, int depth) throws SourceException, SourceNotFoundException {
    try {
        boolean update = false;
        if (action != WebdavResource.NOACTION) {
            if (action > this.action) {
                this.action = action;
                update = true;
            } else {
                action = this.action;
            }
        }
        if (depth > this.depth) {
            this.depth = depth;
            update = true;
        } else {
            depth = this.depth;
        }
        if (this.resource == null) {
            this.resource = new WebdavResource(this.url, action, depth);
        } else if (update) {
            this.resource.setProperties(action, depth);
        }
        if (this.action > WebdavResource.NOACTION) {
            if (this.resource.isCollection()) {
                String path = this.url.getPath();
                if (path.charAt(path.length() - 1) != '/') {
                    this.url.setPath(path + "/");
                }
            }
        }
    } catch (HttpException e) {
        if (e.getReasonCode() == HttpStatus.SC_NOT_FOUND) {
            throw new SourceNotFoundException("Not found: " + getSecureURI(), e);
        }
        if (e.getReasonCode() == HttpStatus.SC_BAD_REQUEST) {
            throw new SourceException("Server doesn't appear to understand WebDAV: " + getSecureURI(), e);
        }
        final String msg = "Could not initialize webdav resource at " + getSecureURI() + ". Server responded "
                + e.getReasonCode() + " (" + e.getReason() + ") - " + e.getMessage();
        throw new SourceException(msg, e);
    } catch (IOException e) {
        throw new SourceException("Could not initialize webdav resource", e);
    }
}

From source file:org.apache.falcon.regression.lineage.LineageApiTest.java

/**
 * Negative test - get a vertex specifying an invalid id, we should not get http non-found
 * error./*www  . j  a  v  a  2  s .c o m*/
 * @throws Exception
 */
@Test
public void testVertexInvalidId() throws Exception {
    final VerticesResult allVerticesResult = lineageHelper.getAllVertices();
    GraphAssert.assertVertexSanity(allVerticesResult);
    int invalidVertexId = -1;
    for (Vertex vertex : allVerticesResult.getResults()) {
        if (invalidVertexId <= vertex.getId()) {
            invalidVertexId = vertex.getId() + 1;
        }
    }

    HttpResponse response = lineageHelper
            .runGetRequest(lineageHelper.getUrl(LineageHelper.URL.VERTICES, "" + invalidVertexId));
    String responseString = lineageHelper.getResponseString(response);
    LOGGER.info("response: " + response);
    LOGGER.info("responseString: " + responseString);
    Assert.assertTrue(responseString.matches(String.format(VERTEX_NOT_FOUND_REGEX, invalidVertexId)),
            "Unexpected responseString: " + responseString);
    Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_NOT_FOUND,
            "We should get http not found error");
}

From source file:org.apache.falcon.regression.lineage.LineageApiTest.java

/**
 * Test vertex properties supplying a blank id, expecting http not found error.
 * @throws Exception/* ww w  .ja v a2s.c o  m*/
 */
@Test
public void testVertexPropertiesNoId() throws Exception {
    //testing properties of a user vertex
    HttpResponse response = lineageHelper.runGetRequest(
            lineageHelper.getUrl(LineageHelper.URL.VERTICES_PROPERTIES, lineageHelper.getUrlPath("")));
    String responseString = lineageHelper.getResponseString(response);
    LOGGER.info("response: " + response);
    LOGGER.info("responseString: " + responseString);
    Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_NOT_FOUND,
            "We should get http not found error");
}

From source file:org.apache.falcon.regression.lineage.LineageApiTest.java

/**
 * Test vertex properties supplying an invalid id, expecting http not found error.
 * @throws Exception/*ww w .  j  a v  a  2s  .  c  o m*/
 */
@Test
public void testVertexPropertiesInvalidId() throws Exception {
    final VerticesResult allVerticesResult = lineageHelper.getAllVertices();
    GraphAssert.assertVertexSanity(allVerticesResult);

    int invalidVertexId = -1;
    for (Vertex vertex : allVerticesResult.getResults()) {
        if (invalidVertexId <= vertex.getId()) {
            invalidVertexId = vertex.getId() + 1;
        }
    }

    HttpResponse response = lineageHelper
            .runGetRequest(lineageHelper.getUrl(LineageHelper.URL.VERTICES_PROPERTIES, "" + invalidVertexId));
    String responseString = lineageHelper.getResponseString(response);
    LOGGER.info("response: " + response);
    LOGGER.info("responseString: " + responseString);
    Assert.assertTrue(responseString.matches(String.format(VERTEX_NOT_FOUND_REGEX, invalidVertexId)),
            "Unexpected responseString: " + responseString);
    Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_NOT_FOUND,
            "We should get http not found error");
}