diff options
Diffstat (limited to 'proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java')
-rw-r--r-- | proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java new file mode 100644 index 0000000..fbcb191 --- /dev/null +++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2009 Red Hat, Inc. + * + * This software is licensed to you under the GNU General Public License, + * version 2 (GPLv2). There is NO WARRANTY for this software, express or + * implied, including the implied warranties of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 + * along with this software; if not, see + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + * + * Red Hat trademarks are not licensed under GPLv2. No permission is + * granted to use or replicate Red Hat trademarks that are incorporated + * in this software or its documentation. + */ + + + +package org.fedoraproject.candlepin.model.test; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.fedoraproject.candlepin.model.Certificate; +import org.fedoraproject.candlepin.model.Owner; +import org.fedoraproject.candlepin.test.DatabaseTestFixture; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + + +public class CertificateTest extends DatabaseTestFixture { + + @Before + public void setUpTestObjects() { + + String ownerName = "Example Corporation"; + Owner owner = new Owner(ownerName); + + ownerCurator.create(owner); + certificateCurator.create( + new Certificate("This is not actually a certificate. No entitlements for you!", owner)); + } + + + @Ignore + public void testGetCertificate() { + Certificate newCertificate = new Certificate(); + } + + @Test + public void testList() throws Exception { + List<Certificate> certificates = certificateCurator.findAll(); + int beforeCount = certificates.size(); + + for (int i = 0; i < 10; i++) { + Owner owner = new Owner("owner" + i); + ownerCurator.create(owner); + certificateCurator.create(new Certificate("this is a test", owner)); + } + + certificates = certificateCurator.findAll(); + int afterCount = certificates.size(); + assertEquals(10, afterCount - beforeCount); + } + + @Test + public void testLookup() throws Exception { + + Owner owner = new Owner("test company"); + Certificate certificate = new Certificate("not a cert", owner); + + ownerCurator.create(owner); + certificateCurator.create(certificate); + + Certificate lookedUp = certificateCurator.find(certificate.getId()); + + assertEquals(certificate.getId(), lookedUp.getId()); + assertEquals(certificate.getCertificate(), lookedUp.getCertificate()); + } +} + |