Examples of MongoDBChangeSet


Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        // verify that the change set was persisted
        ChangeSetDAO changeSetDAO = new ChangeSetDAO(morphia, connection, "rhqtest");
        List<MongoDBChangeSet> changeSets = changeSetDAO.find().asList();

        assertEquals(changeSets.size(), 1, "Expected to find one change set in the database.");
        MongoDBChangeSet actual = changeSets.get(0);

        MongoDBChangeSet expected = new MongoDBChangeSet();
        // Need to set the id to actual.id. Since ids are random, we cannot use a canned
        // value. We have to set it the same value that is in the database.
        expected.setId(actual.getId());
        expected.setDriftDefinitionId(driftDefId);
        expected.setResourceId(resourceId);
        expected.setDriftDefinitionName(driftDefName);
        expected.setCategory(COVERAGE);
        expected.setVersion(0);
        expected.setDriftHandlingMode(normal);

        MongoDBChangeSetEntry entry1 = new MongoDBChangeSetEntry("1.bin", FILE_ADDED);
        entry1.setNewFileHash(file1SHA);
        expected.add(entry1);

        MongoDBChangeSetEntry entry2 = new MongoDBChangeSetEntry("2.bin", FILE_ADDED);
        entry2.setNewFileHash(file2SHA);
        expected.add(entry2);

        String[] ignore = new String[] {"id", "objectId", "ctime"};
        assertChangeSetMatches("Failed to persist change set", expected, actual, ignore);

        DriftChangeSetSummary expectedSummary = new DriftChangeSetSummary();
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        // verify that the change set was persisted
        ChangeSetDAO changeSetDAO = new ChangeSetDAO(morphia, connection, "rhqtest");
        List<MongoDBChangeSet> changeSets = changeSetDAO.find().asList();

        assertEquals(changeSets.size(), 1, "Expected to find one change set in the database.");
        MongoDBChangeSet actual = changeSets.get(0);

        MongoDBChangeSet expected = new MongoDBChangeSet();
        // Need to set the id to actual.id. Since ids are random, we cannot use a canned
        // value. We have to set it the same value that is in the database.
        expected.setId(actual.getId());
        expected.setDriftDefinitionId(driftDefId);
        expected.setResourceId(resourceId);
        expected.setDriftDefinitionName(driftDefName);
        expected.setCategory(DRIFT);
        expected.setVersion(1);
        expected.setDriftHandlingMode(normal);

        MongoDBChangeSetEntry entry1 = new MongoDBChangeSetEntry("1.bin", FILE_CHANGED);
        entry1.setOldFileHash(oldFile1SHA);
        entry1.setNewFileHash(newFile1SHA);
        expected.add(entry1);

        MongoDBChangeSetEntry entry2 = new MongoDBChangeSetEntry("2.bin", FILE_REMOVED);
        entry2.setOldFileHash(file2SHA);
        expected.add(entry2);

        String[] ignore = new String[] {"id", "objectId", "ctime"};
        assertChangeSetMatches("Failed to persist change set", expected, actual, ignore);

        DriftChangeSetSummary expectedSummary = new DriftChangeSetSummary();
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        File file1 = createRandomFile(getBaseDir(), size);
        File file2 = createRandomFile(getBaseDir(), size);

        driftServer.saveChangeSetFiles(null, createChangeSetContentZipFile(file1, file2));

        MongoDBChangeSet changeSet = new MongoDBChangeSet();
        changeSet.setDriftDefinitionId(1);
        changeSet.setResourceId(1);
        changeSet.setDriftDefinitionName("testdef");
        changeSet.setCategory(COVERAGE);
        changeSet.setVersion(0);
       
        MongoDBChangeSetEntry entry = new MongoDBChangeSetEntry("./1.bin", FILE_ADDED);
        entry.setNewFileHash(file1.getName());
        changeSet.add(entry);
       
        changeSetDAO.save(changeSet);
       
        driftServer.purgeOrphanedContent();
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        String driftDefName = "testdef";
        int driftDefId = 1;
        int resourceId1 = 1;
        int resourceId2 = 2;
       
        MongoDBChangeSet changeSet1 = new MongoDBChangeSet();
        changeSet1.setDriftDefinitionId(driftDefId);
        changeSet1.setDriftDefinitionName(driftDefName);
        changeSet1.setResourceId(resourceId1);
        changeSet1.setCategory(COVERAGE);
        changeSet1.setVersion(0);

        MongoDBChangeSetEntry entry1 = new MongoDBChangeSetEntry("./1.bin", FILE_ADDED);
        entry1.setNewFileHash("./1.bin");
        changeSet1.add(entry1);

        changeSetDAO.save(changeSet1);
       
        MongoDBChangeSet changeSet2 = new MongoDBChangeSet();
        changeSet2.setDriftDefinitionId(driftDefId);
        changeSet2.setDriftDefinitionName(driftDefName);
        changeSet2.setResourceId(resourceId1);
        changeSet2.setCategory(DRIFT);
        changeSet2.setVersion(1);

        MongoDBChangeSetEntry entry2 = new MongoDBChangeSetEntry("./1.bin", FILE_CHANGED);
        entry2.setNewFileHash(sha256("./1.bin.new"));
        entry2.setOldFileHash(sha256("./1.bin"));
        changeSet2.add(entry2);
       
        MongoDBChangeSetEntry entry3 = new MongoDBChangeSetEntry("./2.bin", FILE_ADDED);
        entry3.setNewFileHash("./2.bin");
        changeSet2.add(entry3);
       
        changeSetDAO.save(changeSet2);
       

        MongoDBChangeSet changeSet3 = new MongoDBChangeSet();
        changeSet3.setDriftDefinitionId(driftDefId);
        changeSet3.setDriftDefinitionName(driftDefName);
        changeSet3.setResourceId(resourceId2);
        changeSet3.setCategory(COVERAGE);
        changeSet3.setVersion(0);
       
        MongoDBChangeSetEntry entry4 = new MongoDBChangeSetEntry("./3.bin", FILE_ADDED);
        entry4.setNewFileHash(sha256("./3.bin"));
        changeSet3.add(entry4);
        changeSetDAO.save(changeSet3);
       
        GenericDriftChangeSetCriteria criteria = new GenericDriftChangeSetCriteria();
        criteria.addFilterDriftDefinitionId(driftDefId);
        criteria.addFilterResourceId(resourceId1);
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        String driftDefName = "testdef";
        int driftDefId = 1;
        int resourceId1 = 1;
        int resourceId2 = 2;

        MongoDBChangeSet changeSet1 = new MongoDBChangeSet();
        changeSet1.setDriftDefinitionId(driftDefId);
        changeSet1.setDriftDefinitionName(driftDefName);
        changeSet1.setResourceId(resourceId1);
        changeSet1.setCategory(COVERAGE);
        changeSet1.setVersion(0);

        MongoDBChangeSetEntry entry1 = new MongoDBChangeSetEntry("./1.bin", FILE_ADDED);
        entry1.setNewFileHash("./1.bin");
        changeSet1.add(entry1);

        changeSetDAO.save(changeSet1);

        MongoDBChangeSet changeSet2 = new MongoDBChangeSet();
        changeSet2.setDriftDefinitionId(driftDefId);
        changeSet2.setDriftDefinitionName(driftDefName);
        changeSet2.setResourceId(resourceId1);
        changeSet2.setCategory(DRIFT);
        changeSet2.setVersion(1);

        MongoDBChangeSetEntry entry2 = new MongoDBChangeSetEntry("./1.bin", FILE_CHANGED);
        entry2.setNewFileHash(sha256("./1.bin.new"));
        entry2.setOldFileHash(sha256("./1.bin"));
        changeSet2.add(entry2);

        MongoDBChangeSetEntry entry3 = new MongoDBChangeSetEntry("./2.bin", FILE_ADDED);
        entry3.setNewFileHash("./2.bin");
        changeSet2.add(entry3);

        changeSetDAO.save(changeSet2);


        MongoDBChangeSet changeSet3 = new MongoDBChangeSet();
        changeSet3.setDriftDefinitionId(driftDefId);
        changeSet3.setDriftDefinitionName(driftDefName);
        changeSet3.setResourceId(resourceId2);
        changeSet3.setCategory(COVERAGE);
        changeSet3.setVersion(0);

        MongoDBChangeSetEntry entry4 = new MongoDBChangeSetEntry("./3.bin", FILE_ADDED);
        entry4.setNewFileHash(sha256("./3.bin"));
        changeSet3.add(entry4);
        changeSetDAO.save(changeSet3);

        GenericDriftChangeSetCriteria criteria = new GenericDriftChangeSetCriteria();
        criteria.addFilterDriftDefinitionId(driftDefId);
        criteria.addFilterResourceId(resourceId1);
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        String driftDefName = "testdef";
        int driftDefId = 1;
        int resourceId1 = 1;
        int resourceId2 = 2;

        MongoDBChangeSet changeSet1 = new MongoDBChangeSet();
        changeSet1.setDriftDefinitionId(driftDefId);
        changeSet1.setDriftDefinitionName(driftDefName);
        changeSet1.setResourceId(resourceId1);
        changeSet1.setCategory(COVERAGE);
        changeSet1.setVersion(0);

        MongoDBChangeSetEntry entry1 = new MongoDBChangeSetEntry("./1.bin", FILE_ADDED);
        entry1.setNewFileHash("./1.bin");
        changeSet1.add(entry1);

        changeSetDAO.save(changeSet1);

        MongoDBChangeSet changeSet2 = new MongoDBChangeSet();
        changeSet2.setDriftDefinitionId(driftDefId);
        changeSet2.setDriftDefinitionName(driftDefName);
        changeSet2.setResourceId(resourceId1);
        changeSet2.setCategory(DRIFT);
        changeSet2.setVersion(1);

        MongoDBChangeSetEntry entry2 = new MongoDBChangeSetEntry("./1.bin", FILE_CHANGED);
        entry2.setNewFileHash(sha256("./1.bin.new"));
        entry2.setOldFileHash(sha256("./1.bin"));
        changeSet2.add(entry2);

        MongoDBChangeSetEntry entry3 = new MongoDBChangeSetEntry("./2.bin", FILE_ADDED);
        entry3.setNewFileHash("./2.bin");
        changeSet2.add(entry3);

        changeSetDAO.save(changeSet2);


        MongoDBChangeSet changeSet3 = new MongoDBChangeSet();
        changeSet3.setDriftDefinitionId(driftDefId);
        changeSet3.setDriftDefinitionName(driftDefName);
        changeSet3.setResourceId(resourceId2);
        changeSet3.setCategory(COVERAGE);
        changeSet3.setVersion(0);

        MongoDBChangeSetEntry entry4 = new MongoDBChangeSetEntry("./3.bin", FILE_ADDED);
        entry4.setNewFileHash(sha256("./3.bin"));
        changeSet3.add(entry4);
        changeSetDAO.save(changeSet3);

        GenericDriftCriteria criteria = new GenericDriftCriteria();
        criteria.addFilterResourceIds(resourceId1);
        criteria.addFilterDriftDefinitionId(driftDefId);
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        dao = new ChangeSetDAO(morphia, connection, "rhqtest");
    }

    @Test(enabled = ENABLED)
    public void saveAndLoadEmptyChangeSet() throws Exception {
        MongoDBChangeSet expected = new MongoDBChangeSet();
        expected.setCategory(COVERAGE);
        expected.setVersion(1);
        expected.setDriftDefinitionId(1);
        expected.setResourceId(1);
        expected.setDriftHandlingMode(normal);

        dao.save(expected);
        MongoDBChangeSet actual = dao.get(expected.getObjectId());

        assertChangeSetMatches("Failed to save/load change set with no entries", expected, actual);
    }
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        assertChangeSetMatches("Failed to save/load change set with no entries", expected, actual);
    }

    @Test(enabled = ENABLED)
    public void saveAndLoadChangeSetWithAddedFileEntry() throws Exception {
        MongoDBChangeSet expected = new MongoDBChangeSet();
        expected.setCategory(DRIFT);
        expected.setResourceId(1);
        expected.setDriftDefinitionId(1);
        expected.setVersion(1);

        MongoDBChangeSetEntry entry = new MongoDBChangeSetEntry();
        entry.setCategory(FILE_ADDED);
        entry.setPath("foo");

        // Adding the file to the change set entry causes the test to fail because the
        // custom assert uses the equals method when comparing the MongoDBFile objects and
        // MongoDBFile does not implement equals/hashCode...yet.

        //        MongoDBFile file = new MongoDBFile();
        //        file.setDataSize(1024L);
        //        file.setHashId("a1b2c3d4");
        //        file.setStatus(EMPTY);
        //
        //        entry.setNewDriftFile(file);
        expected.add(entry);

        dao.save(expected);

        MongoDBChangeSet actual = dao.get(expected.getObjectId());

        assertChangeSetMatches("Failed to save/load change set with one entry", expected, actual);
    }
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        assertChangeSetMatches("Failed to save/load change set with one entry", expected, actual);
    }

    @Test(enabled = ENABLED)
    public void saveAndLoadChangeSetWithMultipleEntries() throws Exception {
        MongoDBChangeSet expected = new MongoDBChangeSet();
        expected.setCategory(DRIFT);
        expected.setVersion(1);
        expected.setResourceId(1);
        expected.setDriftDefinitionId(1);
        expected.add(new MongoDBChangeSetEntry("foo", FILE_ADDED)).add(new MongoDBChangeSetEntry("bar", FILE_ADDED));

        dao.save(expected);

        MongoDBChangeSet actual = dao.get(expected.getObjectId());

        assertChangeSetMatches("Failed to save/load change set with multiple entries", expected, actual);
    }
View Full Code Here

Examples of org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet

        assertChangeSetMatches("Failed to save/load change set with multiple entries", expected, actual);
    }

    @Test(enabled = ENABLED)
    public void findByChangeSetCriteriaWithIdFilter() throws Exception {
        MongoDBChangeSet c1 = new MongoDBChangeSet();
        c1.setCategory(DRIFT);
        c1.setVersion(1);
        c1.setResourceId(1);
        c1.setDriftDefinitionId(1);
        dao.save(c1);

        MongoDBChangeSet c2 = new MongoDBChangeSet();
        c2.setCategory(DRIFT);
        c2.setVersion(1);
        c2.setResourceId(2);
        c2.setDriftDefinitionId(2);
        dao.save(c2);

        GenericDriftChangeSetCriteria criteria = new GenericDriftChangeSetCriteria();
        criteria.addFilterId(c1.getId());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.