Package org.rhq.core.domain.drift.dto

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


                em.persist(driftDef);
            }
        });

        // create the change set to be persisted
        DriftChangeSetDTO changeSet = new DriftChangeSetDTO();
        changeSet.setCategory(COVERAGE);
        changeSet.setVersion(1);
        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();
View Full Code Here


        // create the change set to be persisted
        //
        // Note that we do not set the drift definition id or resource id since
        // the change set is not owned by a resource. It is owned by the
        // resource type.
        DriftChangeSetDTO changeSet = new DriftChangeSetDTO();
        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();
View Full Code Here

        driftDef.getResource().setAgentSynchronizationNeeded();

        DriftSnapshotRequest snapshotRequest = new DriftSnapshotRequest(driftDefId, snapshotVersion);
        DriftSnapshot snapshot = getSnapshot(subject, snapshotRequest);

        DriftChangeSetDTO changeSet = new DriftChangeSetDTO();
        changeSet.setCategory(COVERAGE);
        changeSet.setVersion(0);
        changeSet.setDriftDefinitionId(driftDefId);
        changeSet.setDriftHandlingMode(DriftHandlingMode.normal);
        changeSet.setResourceId(driftDef.getResource().getId());

        DriftServerPluginFacet driftServerPlugin = getServerPlugin();
        try {
            driftServerPlugin.purgeByDriftDefinitionName(subject, driftDef.getResource().getId(), driftDef.getName());
            persistSnapshot(subject, snapshot, changeSet);
View Full Code Here

    @TransactionAttribute(NOT_SUPPORTED)
    public String persistSnapshot(Subject subject, DriftSnapshot snapshot,
        DriftChangeSet<? extends Drift<?, ?>> changeSet) {
        authorizeOrFail(subject, changeSet.getResourceId(), "Can not update/create drifts");
        DriftChangeSetDTO changeSetDTO = new DriftChangeSetDTO();
        changeSetDTO.setCategory(changeSet.getCategory());
        changeSetDTO.setDriftHandlingMode(changeSet.getDriftHandlingMode());
        changeSetDTO.setVersion(changeSet.getVersion());
        changeSetDTO.setDriftDefinitionId(changeSet.getDriftDefinitionId());
        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();
        try {
            return driftServerPlugin.persistChangeSet(subject, changeSetDTO);
        } catch (Exception e) {
View Full Code Here

    @TransactionAttribute
    public void createTemplateChangeSet(Subject subject, int templateId, int driftDefId, int snapshotVersion) {
        DriftDefinitionTemplate template = entityMgr.find(DriftDefinitionTemplate.class, templateId);
        DriftSnapshot snapshot = driftMgr.getSnapshot(subject, new DriftSnapshotRequest(driftDefId, snapshotVersion));

        DriftChangeSetDTO changeSetDTO = new DriftChangeSetDTO();
        changeSetDTO.setCategory(COVERAGE);
        changeSetDTO.setDriftHandlingMode(normal);
        changeSetDTO.setVersion(0);

        String newChangeSetId = driftMgr.persistSnapshot(subject, snapshot, changeSetDTO);
        template.setChangeSetId(newChangeSetId);
    }
View Full Code Here

        changeSet.setResourceId(1);
        changeSet.setVersion(1);
        changeSet.setDriftHandlingMode(normal);

        Mapper mapper = new Mapper();
        DriftChangeSetDTO actual = mapper.toDTO(changeSet);

        DriftChangeSetDTO expected = new DriftChangeSetDTO();
        expected.setId(changeSet.getId());
        expected.setCategory(changeSet.getCategory());
        expected.setCtime(changeSet.getCtime());
        expected.setDriftDefinitionId(changeSet.getDriftDefinitionId());
        expected.setResourceId(changeSet.getResourceId());
        expected.setDriftHandlingMode(changeSet.getDriftHandlingMode());
        expected.setVersion(changeSet.getVersion());

        assertPropertiesMatch(expected, actual, "Failed to map " + MongoDBChangeSet.class.getSimpleName() + " to " +
                DriftChangeSetDTO.class.getSimpleName());
    }
View Full Code Here

        criteria.addFilterDriftDefinitionId(driftDefId);
        criteria.addFilterResourceId(resourceId1);
        criteria.addFilterVersion("1");

        Mapper mapper = new Mapper();
        DriftChangeSetDTO expected = mapper.toDTO(changeSet2);
       
        PageList<? extends DriftChangeSet<?>> actualChangeSets = driftServer.findDriftChangeSetsByCriteria(null,
                criteria);
       
        assertEquals(actualChangeSets.size(), 1, "Expected to get back one change set.");
        DriftChangeSetDTO actual = (DriftChangeSetDTO) actualChangeSets.get(0);

        assertChangeSetMatches("Failed to return change set DTO", expected, actual);
        assertTrue(actual.getDrifts().isEmpty(), "Drifts should not have been returned since criteria did not " +
                "specify to fetch drifts");
    }
View Full Code Here

        criteria.addFilterResourceId(resourceId1);
        criteria.addFilterVersion("1");
        criteria.fetchDrifts(true);

        Mapper mapper = new Mapper();
        DriftChangeSetDTO expected = mapper.toDTO(changeSet2);


        PageList<? extends DriftChangeSet<?>> actualChangeSets = driftServer.findDriftChangeSetsByCriteria(null,
                criteria);

        assertEquals(actualChangeSets.size(), 1, "Expected to get back one change set.");
        DriftChangeSetDTO actual = (DriftChangeSetDTO) actualChangeSets.get(0);

        assertChangeSetMatches("Failed to return change set DTO", expected, actual);
        assertEquals(actual.getDrifts().size(), 2, "Expected change set to contain two drifts");

        assertDriftMatches("The drift should have been included in the change set", mapper.toDTO(entry2),
                find(actual.getDrifts(), "./1.bin"));
        assertDriftMatches("The drift should have been included in the change set", mapper.toDTO(entry3),
                find(actual.getDrifts(), "./2.bin"));
    }
View Full Code Here

        driftServer.driftDef = driftDef;
                       
        int resourceId = 1;

        // First create the change set from which the pinned change set will be created
        DriftChangeSetDTO changeSetDTO = new DriftChangeSetDTO();
        changeSetDTO.setResourceId(resourceId);
        changeSetDTO.setDriftDefinitionId(driftDef.getId());
        changeSetDTO.setDriftHandlingMode(plannedChanges);
        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));
        }
View Full Code Here

    }
   
    @Test
    public void persistNewChangeSetForPinnedTemplate() throws Exception {
        // First create the change set from which the pinned change set will be created
        DriftChangeSetDTO changeSetDTO = new DriftChangeSetDTO();
        changeSetDTO.setDriftHandlingMode(plannedChanges);
        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));
        }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.drift.dto.DriftChangeSetDTO

Copyright © 2018 www.massapicom. 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.