Exemplo n.º 1
0
 public void testContentSource() throws Exception {
   Channel c = ChannelFactoryTest.createTestChannel(user);
   ContentSource cs = new ContentSource();
   cs.setLabel("repo_label-" + c.getLabel());
   cs.setSourceUrl("fake url");
   List<ContentSourceType> cst = ChannelFactory.listContentSourceTypes();
   cs.setType(cst.get(0));
   cs.setOrg(user.getOrg());
   cs = (ContentSource) TestUtils.saveAndReload(cs);
   c.getSources().add(cs);
   c = (Channel) TestUtils.saveAndReload(c);
   assertNotEmpty(c.getSources());
 }
  public void testUpgradable() throws Exception {
    Map info =
        ErrataCacheManagerTest.createServerNeededPackageCache(user, ErrataFactory.ERRATA_TYPE_BUG);
    Server s = (Server) info.get("server");
    Package p = (Package) info.get("package");
    p = (Package) TestUtils.saveAndReload(p);

    DataResult<UpgradablePackageListItem> dr = PackageManager.upgradable(s.getId(), null);
    assertFalse(dr.isEmpty());
    boolean containsSamePackage = false;
    for (UpgradablePackageListItem item : dr) {
      if (p.getPackageName().getName().equals(item.getName())) {
        containsSamePackage = true;
      }
      assertTrue(item.getIdCombo().split("\\|").length == 3);
    }
    assertTrue(containsSamePackage);
  }
  public void testUpgradablePackagesFromServerSet() throws Exception {
    // Setup
    User admin = UserTestUtils.findNewUser("ssmUpgradeUser1", "ssmUpgradeOrg1");
    Org org = admin.getOrg();

    //   Create the server and add to the SSM
    Server server = ServerTestUtils.createTestSystem(admin);
    ServerTestUtils.addServersToSsm(admin, server.getId());

    //   Create upgraded package EVR so package will show up from the query
    PackageEvr upgradedPackageEvr = PackageEvrFactory.createPackageEvr("1", "1.0.0", "2");
    upgradedPackageEvr = (PackageEvr) TestUtils.saveAndReload(upgradedPackageEvr);

    ServerTestUtils.populateServerErrataPackages(
        org, server, upgradedPackageEvr, ErrataFactory.ERRATA_TYPE_SECURITY);
    ServerTestUtils.populateServerErrataPackages(
        org, server, upgradedPackageEvr, ErrataFactory.ERRATA_TYPE_BUG);

    // Test
    DataResult result = PackageManager.upgradablePackagesFromServerSet(admin);

    assertTrue(result != null);
    assertEquals(2, result.size());
  }