public static Resource multiplyAndAddTo(
      Resource lhs, Resource rhs, double by) {
    int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
    for (int i = 0; i < maxLength; i++) {
      try {
        ResourceInformation rhsValue = rhs.getResourceInformation(i);
        ResourceInformation lhsValue = lhs.getResourceInformation(i);

        long convertedRhs = (long) (rhsValue.getValue() * by);
        lhs.setResourceValue(i, lhsValue.getValue() + convertedRhs);
      } catch (ResourceNotFoundException ye) {
        LOG.warn("Resource is missing:" + ye.getMessage());
      }
    }
    return lhs;
  }
@Test
  void testMultiplyAndAddTo() throws Exception {
    unsetExtraResourceType();
    setupExtraResourceType();
    assertEquals(createResource(6, 4),
        multiplyAndAddTo(createResource(3, 1), createResource(2, 2), 1.5));
    assertEquals(createResource(6, 4, 0),
        multiplyAndAddTo(createResource(3, 1), createResource(2, 2), 1.5));
    assertEquals(createResource(4, 7),
        multiplyAndAddTo(createResource(1, 1), createResource(2, 4), 1.5));
    assertEquals(createResource(4, 7, 0),
        multiplyAndAddTo(createResource(1, 1), createResource(2, 4), 1.5));
    assertEquals(createResource(6, 4, 0),
        multiplyAndAddTo(createResource(3, 1, 0), createResource(2, 2, 0),
            1.5));
    assertEquals(createResource(6, 4, 6),
        multiplyAndAddTo(createResource(3, 1, 2), createResource(2, 2, 3),
            1.5));
  }