예제 #1
0
  @Test
  public void testIsNotVirtWhenFactIsFalse() {
    consumer.setFact(IS_VIRT, "false");
    consumer.setFact(SOCKET_FACT, "4");
    pool.getProduct().setAttribute(SOCKET_ATTRIBUTE, "2");

    SuggestedQuantity suggested = quantityRules.getSuggestedQuantity(pool, consumer, new Date());
    assertEquals(new Long(2), suggested.getSuggested());
    assertEquals(new Long(1), suggested.getIncrement());
  }
예제 #2
0
  @Test
  public void testSingleSocketInstanceBasedOnPhysical() {
    consumer.setFact(IS_VIRT, "false");
    consumer.setFact(SOCKET_FACT, "1");
    pool.getProduct().setAttribute(SOCKET_ATTRIBUTE, "1");
    pool.getProduct().setAttribute(INSTANCE_ATTRIBUTE, "2");

    SuggestedQuantity suggested = quantityRules.getSuggestedQuantity(pool, consumer, new Date());
    assertEquals(new Long(2), suggested.getSuggested());
    assertEquals(new Long(2), suggested.getIncrement());
  }
예제 #3
0
  @Test
  public void testInstanceBasedOnPhysicalNotEnoughAvailableUneven() {
    consumer.setFact(IS_VIRT, "false");
    consumer.setFact(SOCKET_FACT, "40"); // lots of ents required
    pool.getProduct().setAttribute(SOCKET_ATTRIBUTE, "2");
    pool.getProduct().setAttribute(INSTANCE_ATTRIBUTE, "2");

    pool.setQuantity(3L);
    SuggestedQuantity suggested = quantityRules.getSuggestedQuantity(pool, consumer, new Date());
    assertEquals(new Long(2), suggested.getSuggested());
    assertEquals(new Long(2), suggested.getIncrement());
  }
예제 #4
0
  /*
   * Distributors should always get suggested=1, increment=1
   */
  @Test
  public void testInstanceBasedOnDistributor() {
    Consumer dist = TestUtil.createConsumer(owner);
    dist.getType().setManifest(true);
    dist.setFact(IS_VIRT, "false");
    dist.setFact(SOCKET_FACT, "4");
    pool.getProduct().setAttribute(SOCKET_ATTRIBUTE, "2");
    pool.getProduct().setAttribute(INSTANCE_ATTRIBUTE, "2");

    SuggestedQuantity suggested = quantityRules.getSuggestedQuantity(pool, dist, new Date());
    assertEquals(new Long(1), suggested.getSuggested());
    assertEquals(new Long(1), suggested.getIncrement());
  }
예제 #5
0
  @Test
  public void testInstanceBasedOnGuest() {
    // Ensure that we start this test with no entitlements.
    consumer.getEntitlements().clear();
    consumer.setFact(IS_VIRT, "true");
    consumer.setFact(SOCKET_FACT, "4");
    pool.getProduct().setAttribute(SOCKET_ATTRIBUTE, "2");
    pool.getProduct().setAttribute(INSTANCE_ATTRIBUTE, "2");

    SuggestedQuantity suggested = quantityRules.getSuggestedQuantity(pool, consumer, new Date());
    assertEquals(new Long(1), suggested.getSuggested());
    assertEquals(new Long(1), suggested.getIncrement());
  }