Package org.candlepin.model

Examples of org.candlepin.model.ExporterMetadata


        emc = injector.getInstance(ExporterMetadataCurator.class);
    }

    @Test
    public void testCreation() {
        ExporterMetadata em = new ExporterMetadata();
        em.setType(ExporterMetadata.TYPE_SYSTEM);
        em.setExported(new Date());
        assertNull(em.getId());
        ExporterMetadata emdb = emc.create(em);
        assertNotNull(emdb);
        assertNotNull(emdb.getId());
        assertNull(emdb.getOwner());
    }
View Full Code Here


        assertNull(emdb.getOwner());
    }

    @Test
    public void testLookup() {
        ExporterMetadata em = new ExporterMetadata();
        em.setType(ExporterMetadata.TYPE_SYSTEM);
        em.setExported(new Date());
        assertNull(em.getId());
        ExporterMetadata emdb = emc.create(em);
        ExporterMetadata emfound = emc.find(emdb.getId());
        assertNotNull(emfound);
        assertNotNull(emfound.getId());
        assertEquals(emdb.getId(), emfound.getId());
    }
View Full Code Here

        assertEquals(emdb.getId(), emfound.getId());
    }

    @Test
    public void lookupByType() {
        ExporterMetadata em = new ExporterMetadata();
        em.setType(ExporterMetadata.TYPE_SYSTEM);
        em.setExported(new Date());
        assertNull(em.getId());
        ExporterMetadata emdb = emc.create(em);

        assertNull(emc.lookupByType(ExporterMetadata.TYPE_PER_USER));
        assertEquals(emdb, emc.lookupByType(ExporterMetadata.TYPE_SYSTEM));
    }
View Full Code Here

        assertEquals(emdb, emc.lookupByType(ExporterMetadata.TYPE_SYSTEM));
    }

    @Test
    public void setOwner() {
        ExporterMetadata em = new ExporterMetadata();
        em.setType(ExporterMetadata.TYPE_PER_USER);
        em.setExported(new Date());
        em.setOwner(createOwner());
        ExporterMetadata emdb = emc.create(em);
        assertNotNull(emdb);
        assertNotNull(emdb.getOwner());
        assertNotNull(emdb.getOwner().getId());
    }
View Full Code Here

        assertNotNull(emdb.getOwner().getId());
    }

    @Test
    public void lookupByTypeAndOwner() {
        ExporterMetadata em = new ExporterMetadata();
        Owner owner = createOwner();
        em.setType(ExporterMetadata.TYPE_PER_USER);
        em.setExported(new Date());
        em.setOwner(owner);
        ExporterMetadata emdb = emc.create(em);

        assertEquals(emdb, emc.lookupByTypeAndOwner(
            ExporterMetadata.TYPE_PER_USER, owner));
    }
View Full Code Here

            null, null, null, i18n, es, null, null, null, null, null, ec,
            null, importRecordCurator, null, null, null, null, null,
            null, null, null, contentOverrideValidator,
            serviceLevelValidator, null);

        ExporterMetadata metadata = new ExporterMetadata();
        when(ec.lookupByTypeAndOwner(ExporterMetadata.TYPE_PER_USER, owner))
            .thenReturn(metadata);
        when(sc.listByOwner(owner)).thenReturn(new ArrayList<Subscription>());

        thisOwnerResource.undoImports(owner.getKey(),
View Full Code Here

        File file = createFile("meta", "0.0.3", now,
            "test_user", "prefix");
        File actual = createFile("meta.json", "0.0.3", now,
            "test_user", "prefix");
        ExporterMetadataCurator emc = mock(ExporterMetadataCurator.class);
        ExporterMetadata em = new ExporterMetadata();
        Date daybefore = getDateBeforeDays(1);
        em.setExported(daybefore);
        em.setId("42");
        em.setType(ExporterMetadata.TYPE_SYSTEM);
        when(emc.lookupByType(ExporterMetadata.TYPE_SYSTEM)).thenReturn(em);
        Importer i = new Importer(null, null, null, null, null, null, null,
            null, null, null, emc, null, null, i18n, null, null);
        i.validateMetadata(ExporterMetadata.TYPE_SYSTEM, null, actual,
            new ConflictOverrides());

        Meta fileMeta = mapper.readValue(file, Meta.class);
        Meta actualMeta = mapper.readValue(actual, Meta.class);
        assertEquals(fileMeta.getPrincipalName(), actualMeta.getPrincipalName());
        assertEquals(fileMeta.getCreated().getTime(), actualMeta.getCreated().getTime());
        assertEquals(fileMeta.getWebAppPrefix(), actualMeta.getWebAppPrefix());

        assertTrue(file.delete());
        assertTrue(actual.delete());
        assertTrue(daybefore.compareTo(em.getExported()) < 0);
    }
View Full Code Here

        // actualmeta is the mock for the import itself
        File actualmeta = createFile("meta.json", "0.0.3", getDateBeforeDays(10),
            "test_user", "prefix");
        ExporterMetadataCurator emc = mock(ExporterMetadataCurator.class);
        // emc is the mock for lastrun (i.e., the most recent import in CP)
        ExporterMetadata em = new ExporterMetadata();
        em.setExported(getDateBeforeDays(3));
        em.setId("42");
        em.setType(ExporterMetadata.TYPE_SYSTEM);
        when(emc.lookupByType(ExporterMetadata.TYPE_SYSTEM)).thenReturn(em);
        Importer i = new Importer(null, null, null, null, null, null, null,
            null, null, null, emc, null, null, i18n, null, null);
        try {
            i.validateMetadata(ExporterMetadata.TYPE_SYSTEM, null, actualmeta,
View Full Code Here

        Date date = getDateBeforeDays(10);
        File actualmeta = createFile("meta.json", "0.0.3", date,
            "test_user", "prefix");
        ExporterMetadataCurator emc = mock(ExporterMetadataCurator.class);
        // emc is the mock for lastrun (i.e., the most recent import in CP)
        ExporterMetadata em = new ExporterMetadata();
        em.setExported(date); // exact same date = assumed same manifest
        em.setId("42");
        em.setType(ExporterMetadata.TYPE_SYSTEM);
        when(emc.lookupByType(ExporterMetadata.TYPE_SYSTEM)).thenReturn(em);
        Importer i = new Importer(null, null, null, null, null, null, null,
            null, null, null, emc, null, null, i18n, null, null);
        try {
            i.validateMetadata(ExporterMetadata.TYPE_SYSTEM, null, actualmeta,
View Full Code Here

        // actualmeta is the mock for the import itself
        File actualmeta = createFile("meta.json", "0.0.3", importDate,
            "test_user", "prefix");
        ExporterMetadataCurator emc = mock(ExporterMetadataCurator.class);
        // em is the mock for lastrun (i.e., the most recent import in CP)
        ExporterMetadata em = new ExporterMetadata();
        em.setExported(getDateBeforeDays(30));
        em.setId("42");
        em.setType(ExporterMetadata.TYPE_SYSTEM);
        when(emc.lookupByType(ExporterMetadata.TYPE_SYSTEM)).thenReturn(em);
        Importer i = new Importer(null, null, null, null, null, null, null,
            null, null, null, emc, null, null, i18n, null, null);
        i.validateMetadata(ExporterMetadata.TYPE_SYSTEM, null, actualmeta,
            new ConflictOverrides());
        assertEquals(importDate, em.getExported());
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.ExporterMetadata

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.