Examples of DriftDTO


Examples of org.rhq.core.domain.drift.dto.DriftDTO

        changeSet.setDriftDefinitionId(driftDef.getId());
        changeSet.setResourceId(resource.getId());
        changeSet.setDriftHandlingMode(normal);
        changeSet.setCtime(System.currentTimeMillis());

        DriftDTO drift1 = new DriftDTO();
        drift1.setCategory(FILE_ADDED);
        drift1.setPath("drift.1");
        drift1.setChangeSet(changeSet);
        drift1.setCtime(System.currentTimeMillis());
        drift1.setNewDriftFile(toDTo(driftFile1));

        DriftDTO drift2 = new DriftDTO();
        drift2.setCategory(FILE_ADDED);
        drift2.setPath("drift.2");
        drift2.setChangeSet(changeSet);
        drift2.setCtime(System.currentTimeMillis());
        drift2.setNewDriftFile(toDTo(driftFile2));

        Set<DriftDTO> drifts = new HashSet<DriftDTO>();
        drifts.add(drift1);
        drifts.add(drift2);
        changeSet.setDrifts(drifts);

        String newChangeSetId = jpaDriftServer.persistChangeSet(getOverlord(), changeSet);

        // verify that the change set was persisted
        JPADriftChangeSetCriteria criteria = new JPADriftChangeSetCriteria();
        criteria.addFilterId(newChangeSetId);
        criteria.fetchDrifts(true);

        PageList<JPADriftChangeSet> changeSets = jpaDriftServer.findDriftChangeSetsByCriteria(getOverlord(), criteria);
        assertEquals("Expected to find one change set", 1, changeSets.size());

        JPADriftChangeSet jpaChangeSet = changeSets.get(0);
        assertEquals("Expected change set to contain two drifts. This could be a result of the change set not being "
            + "persisted correctly or the criteria fetch being done incorrectly.", 2, jpaChangeSet.getDrifts().size());

        AssertUtils.assertPropertiesMatch("The change set was not persisted correctly", changeSet, jpaChangeSet, "id",
            "drifts", "class", "ctime");

        List<? extends Drift> expectedDrifts = asList(drift1, drift2);
        List<? extends Drift> actualDrifts = new ArrayList(jpaChangeSet.getDrifts());

        // We ignore the id and ctime properties because those are set by JPADriftServerBean
        // and are somewhat implmentation specific. We ignore the directory property because
        // it is really a calculated property. newDriftFile has to be compared separately
        // since it does not implement equals.
        AssertUtils.assertCollectionMatchesNoOrder("The change set drifts were not persisted correctly",
            (List<Drift>) expectedDrifts, (List<Drift>) actualDrifts, "id", "ctime", "changeSet", "directory",
            "newDriftFile", "class");

        assertPropertiesMatch("The newDriftFile property was not set correctly for " + drift1,
            drift1.getNewDriftFile(), findDriftByPath(actualDrifts, "drift.1").getNewDriftFile(), "class", "ctime");
        assertPropertiesMatch("The newDriftFile property was not set correctly for " + drift2,
            drift2.getNewDriftFile(), findDriftByPath(actualDrifts, "drift.2").getNewDriftFile(), "class", "ctime");
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        changeSet.setCategory(COVERAGE);
        changeSet.setVersion(1);
        changeSet.setDriftHandlingMode(normal);
        changeSet.setCtime(System.currentTimeMillis());

        DriftDTO drift1 = new DriftDTO();
        drift1.setCategory(FILE_ADDED);
        drift1.setPath("drift.1");
        drift1.setChangeSet(changeSet);
        drift1.setCtime(System.currentTimeMillis());
        drift1.setNewDriftFile(toDTo(driftFile1));

        DriftDTO drift2 = new DriftDTO();
        drift2.setCategory(FILE_ADDED);
        drift2.setPath("drift.2");
        drift2.setChangeSet(changeSet);
        drift2.setCtime(System.currentTimeMillis());
        drift2.setNewDriftFile(toDTo(driftFile2));

        Set<DriftDTO> drifts = new HashSet<DriftDTO>();
        drifts.add(drift1);
        drifts.add(drift2);
        changeSet.setDrifts(drifts);

        String newChangeSetId = jpaDriftServer.persistChangeSet(getOverlord(), changeSet);

        // verify that the change set was persisted
        JPADriftChangeSetCriteria criteria = new JPADriftChangeSetCriteria();
        criteria.addFilterId(newChangeSetId);
        criteria.fetchDrifts(true);

        PageList<JPADriftChangeSet> changeSets = jpaDriftServer.findDriftChangeSetsByCriteria(getOverlord(), criteria);
        assertEquals("Expected to find one change set", 1, changeSets.size());

        JPADriftChangeSet jpaChangeSet = changeSets.get(0);
        assertEquals("Expected change set to contain two drifts. This could be a result of the change set not being "
            + "persisted correctly or the criteria fetch being done incorrectly.", 2, jpaChangeSet.getDrifts().size());

        AssertUtils.assertPropertiesMatch("The change set was not persisted correctly", changeSet, jpaChangeSet, "id",
            "drifts", "class", "ctime");

        List<? extends Drift> expectedDrifts = asList(drift1, drift2);
        List<? extends Drift> actualDrifts = new ArrayList(jpaChangeSet.getDrifts());

        // We ignore the id and ctime properties because those are set by JPADriftServerBean
        // and are somewhat implmentation specific. We ignore the directory property because
        // it is really a calculated property. newDriftFile has to be compared separately
        // since it does not implement equals.
        AssertUtils.assertCollectionMatchesNoOrder("The change set drifts were not persisted correctly",
            (List<Drift>) expectedDrifts, (List<Drift>) actualDrifts, "id", "ctime", "changeSet", "directory",
            "newDriftFile", "class");

        assertPropertiesMatch("The newDriftFile property was not set correctly for " + drift1,
            drift1.getNewDriftFile(), findDriftByPath(actualDrifts, "drift.1").getNewDriftFile(), "class", "ctime");
        assertPropertiesMatch("The newDriftFile property was not set correctly for " + drift2,
            drift2.getNewDriftFile(), findDriftByPath(actualDrifts, "drift.2").getNewDriftFile(), "class", "ctime");
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        changeSetDTO.setResourceId(changeSet.getResourceId());

        Set<DriftDTO> drifts = new HashSet<DriftDTO>();
        for (Drift<?, ?> drift : snapshot.getDriftInstances()) {
            // we need to scrub ids and references to owning change sets
            DriftDTO driftDTO = new DriftDTO();
            driftDTO.setCategory(DriftCategory.FILE_ADDED);
            driftDTO.setChangeSet(changeSetDTO);
            driftDTO.setCtime(drift.getCtime());
            driftDTO.setNewDriftFile(toDTO(drift.getNewDriftFile()));
            driftDTO.setPath(drift.getPath());
            driftDTO.setDirectory(drift.getDirectory());
            drifts.add(driftDTO);
        }
        changeSetDTO.setDrifts(drifts);

        DriftServerPluginFacet driftServerPlugin = getServerPlugin();
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        entry.setNewFileHash("1ab2c34d");
        entry.setOldFileHash("4dc32b1a");
        entry.setCategory(FILE_CHANGED);
       
        Mapper mapper = new Mapper();
        DriftDTO actual = mapper.toDTO(entry);
       
        DriftDTO expected = new DriftDTO();
        expected.setId(entry.getId());
        expected.setCategory(entry.getCategory());
        expected.setPath(entry.getPath());
        expected.setDirectory(entry.getDirectory());
        expected.setCtime(entry.getCtime());
        expected.setNewDriftFile(newDriftFileDTO(entry.getNewFileHash()));
        expected.setOldDriftFile(newDriftFileDTO(entry.getOldFileHash()));
       
        assertPropertiesMatch("Failed to map " + MongoDBChangeSetEntry.class.getSimpleName() + " to " +
                DriftDTO.class.getSimpleName(),expected, actual, "oldDriftFile", "newDriftFile");
        assertPropertiesMatch(newDriftFileDTO(entry.getNewFileHash()), actual.getNewDriftFile(),
                "Failed to map newDriftFile property");
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        criteria.addFilterCategories(FILE_CHANGED);
        criteria.addFilterChangeSetStartVersion(1);

        PageList<? extends Drift<?, ?>> actualDrifts = driftServer.findDriftsByCriteria(null, criteria);
        assertEquals(actualDrifts.size(), 1, "Expected to get back one drift");
        DriftDTO actual = (DriftDTO) actualDrifts.get(0);
       
        Mapper mapper = new Mapper();
        DriftDTO expected = mapper.toDTO(entry2);
       
        assertDriftMatches("Failed to return drift DTO", expected, actual);
        assertNull(actual.getChangeSet(), "The change set should not have been included with the returned drift");
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        criteria.addFilterChangeSetStartVersion(1);
        criteria.fetchChangeSet(true);

        PageList<? extends Drift<?, ?>> actualDrifts = driftServer.findDriftsByCriteria(null, criteria);
        assertEquals(actualDrifts.size(), 1, "Expected to get back one drift");
        DriftDTO actual = (DriftDTO) actualDrifts.get(0);

        Mapper mapper = new Mapper();
        DriftDTO expected = mapper.toDTO(entry2);

        assertDriftMatches("Failed to return drift DTO", expected, actual);
        assertChangeSetMatches("The change set should have been fetched", mapper.toDTO(changeSet2),
                actual.getChangeSet());
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        changeSetDTO.setCategory(COVERAGE);
        changeSetDTO.setCtime(new Date().getTime());
        changeSetDTO.setVersion(0);
       
        Set<DriftDTO> driftDTOs = new HashSet<DriftDTO>();
        DriftDTO drift1DTO = new DriftDTO();
        drift1DTO.setChangeSet(changeSetDTO);
        drift1DTO.setCategory(FILE_ADDED);
        drift1DTO.setPath("./1.bin");
        drift1DTO.setDirectory(".");
        drift1DTO.setCtime(new Date().getTime());
        drift1DTO.setNewDriftFile(newDriftFile(sha256("./1.bin")));
        driftDTOs.add(drift1DTO);
       
        DriftDTO drift2DTO = new DriftDTO();
        drift2DTO.setChangeSet(changeSetDTO);
        drift2DTO.setCategory(FILE_ADDED);
        drift2DTO.setPath("./2.bin");
        drift2DTO.setDirectory(".");
        drift2DTO.setCtime(new Date().getTime());
        drift2DTO.setNewDriftFile(newDriftFile(sha256("./2.bin")));
        driftDTOs.add(drift2DTO);

        changeSetDTO.setDrifts(driftDTOs);

        driftServer.persistChangeSet(null, changeSetDTO);

        GenericDriftChangeSetCriteria criteria = new GenericDriftChangeSetCriteria();
        criteria.addFilterDriftDefinitionId(driftDef.getId());
        criteria.fetchDrifts(true);
       
        List<MongoDBChangeSet> changeSets = changeSetDAO.findByChangeSetCritiera(criteria);
        assertEquals(changeSets.size(), 1, "There should only be one change set for drift definition id " +
                driftDef.getId());

        Mapper mapper = new Mapper();
        DriftChangeSetDTO actualChangeSet = mapper.toDTO(changeSets.get(0));
        Set<DriftDTO> actualDrifts = new HashSet<DriftDTO>();
        for (MongoDBChangeSetEntry entry : changeSets.get(0).getDrifts()) {
            actualDrifts.add(mapper.toDTO(entry));
        }

        assertChangeSetMatches("Failed to persist change set", changeSetDTO, actualChangeSet);
        assertDriftMatches("The drift should have been persisted in the change set", drift1DTO,
                find(actualDrifts, "./1.bin"));
        assertDriftFileMatches("Failed to persist the drift file data", drift1DTO.getNewDriftFile(),
                find(actualDrifts, "./1.bin").getNewDriftFile());
        assertDriftMatches("The drift should have been persisted in the change set", drift2DTO,
                find(actualDrifts, "./2.bin"));
        assertDriftFileMatches("Failed to persist the drift file data", drift2DTO.getNewDriftFile(),
                find(actualDrifts, "./2.bin").getNewDriftFile());
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        changeSetDTO.setCategory(COVERAGE);
        changeSetDTO.setCtime(new Date().getTime());
        changeSetDTO.setVersion(0);

        Set<DriftDTO> driftDTOs = new HashSet<DriftDTO>();
        DriftDTO drift1DTO = new DriftDTO();
        drift1DTO.setChangeSet(changeSetDTO);
        drift1DTO.setCategory(FILE_ADDED);
        drift1DTO.setPath("./1.bin");
        drift1DTO.setDirectory(".");
        drift1DTO.setCtime(new Date().getTime());
        drift1DTO.setNewDriftFile(newDriftFile(sha256("./1.bin")));
        driftDTOs.add(drift1DTO);

        DriftDTO drift2DTO = new DriftDTO();
        drift2DTO.setChangeSet(changeSetDTO);
        drift2DTO.setCategory(FILE_ADDED);
        drift2DTO.setPath("./2.bin");
        drift2DTO.setDirectory(".");
        drift2DTO.setCtime(new Date().getTime());
        drift2DTO.setNewDriftFile(newDriftFile(sha256("./2.bin")));
        driftDTOs.add(drift2DTO);

        changeSetDTO.setDrifts(driftDTOs);

        driftServer.persistChangeSet(null, changeSetDTO);

        GenericDriftChangeSetCriteria criteria = new GenericDriftChangeSetCriteria();
        criteria.fetchDrifts(true);

        List<MongoDBChangeSet> changeSets = changeSetDAO.findByChangeSetCritiera(criteria);
        assertEquals(changeSets.size(), 1, "There should only be one change set.");

        Mapper mapper = new Mapper();
        DriftChangeSetDTO actualChangeSet = mapper.toDTO(changeSets.get(0));
        Set<DriftDTO> actualDrifts = new HashSet<DriftDTO>();
        for (MongoDBChangeSetEntry entry : changeSets.get(0).getDrifts()) {
            actualDrifts.add(mapper.toDTO(entry));
        }

        assertChangeSetMatches("Failed to persist change set", changeSetDTO, actualChangeSet);
        assertDriftMatches("The drift should have been persisted in the change set", drift1DTO,
                find(actualDrifts, "./1.bin"));
        assertDriftFileMatches("Failed to persist the drift file data", drift1DTO.getNewDriftFile(),
                find(actualDrifts, "./1.bin").getNewDriftFile());
        assertDriftMatches("The drift should have been persisted in the change set", drift2DTO,
                find(actualDrifts, "./2.bin"));
        assertDriftFileMatches("Failed to persist the drift file data", drift2DTO.getNewDriftFile(),
                find(actualDrifts, "./2.bin").getNewDriftFile());
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        return dto;
    }
   
    public DriftDTO toDTO(MongoDBChangeSetEntry entry) {
        DriftDTO dto = new DriftDTO();
        dto.setId(entry.getId());
        dto.setCategory(entry.getCategory());
        dto.setCtime(entry.getCtime());
        dto.setPath(entry.getPath());
        dto.setDirectory(entry.getDirectory());
        if (entry.getNewFileHash() != null) {
            dto.setNewDriftFile(newDriftFileDTO(entry.getNewFileHash()));
        }
        if (entry.getOldFileHash() != null) {
            dto.setOldDriftFile(newDriftFileDTO(entry.getOldFileHash()));
        }

        return dto;
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.dto.DriftDTO

        for (MongoDBChangeSet changeSet : changeSets) {
            DriftChangeSetDTO changeSetDTO = mapper.toDTO(changeSet);
            if (criteria.isFetchDrifts()) {
                Set<DriftDTO> entries = new HashSet<DriftDTO>();
                for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
                    DriftDTO driftDTO = mapper.toDTO(entry);
                    driftDTO.setChangeSet(changeSetDTO);
                    entries.add(driftDTO);
                }
                changeSetDTO.setDrifts(entries);
            }
            results.add(changeSetDTO);
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.