ResourceDimensions { public static ResourceDimension fromServerInfo(ServerInfo serverInfo) { return ResourceDimension.newBuilder() .withCpus(serverInfo.getCpus()) .withMemoryMB(serverInfo.getMemoryGB() * 1024) .withDiskMB(serverInfo.getStorageGB() * 1024) .withNetworkMbs(serverInfo.getNetworkMbs()) .withGpu(serverInfo.getGpus()) .build(); }  static ResourceDimension add(ResourceDimension... parts); static ResourceDimension add(Collection<ResourceDimension> parts); static ResourceDimension subtractPositive(ResourceDimension left, ResourceDimension right); static ResourceDimension multiply(ResourceDimension base, double multiplier); static Pair<Long, ResourceDimension> divide(ResourceDimension left, ResourceDimension right); static long divideAndRoundUp(ResourceDimension left, ResourceDimension right); static ResourceDimension alignUp(ResourceDimension source, ResourceDimension reference); static boolean isBigger(ResourceDimension dimension, ResourceDimension subDimension); static StringBuilder format(ResourceDimension input, StringBuilder output); static String format(ResourceDimension input); static ResourceDimension fromServerInfo(ServerInfo serverInfo); static ResourceDimension fromAwsInstanceType(AwsInstanceType instanceType); static ResAllocs toResAllocs(String name, ResourceDimension resourceDimension); static ResourceDimension fromResAllocs(ResAllocs resAllocs);  }
@Test public void testFromServerInfoMapping() throws Exception { ServerInfo m42xl = ServerInfoResolvers.fromAwsInstanceTypes() .resolve(AwsInstanceType.M4_2XLarge.getDescriptor().getId()) .get(); ResourceDimension actual = ResourceDimensions.fromServerInfo(m42xl); AwsInstanceDescriptor descriptor = AwsInstanceType.M4_2XLarge.getDescriptor(); assertThat(actual.getCpu()).isEqualTo(descriptor.getvCPUs()); assertThat(actual.getMemoryMB()).isEqualTo(descriptor.getMemoryGB() * 1024); assertThat(actual.getDiskMB()).isEqualTo(descriptor.getStorageGB() * 1024); assertThat(actual.getNetworkMbs()).isEqualTo(descriptor.getNetworkMbs()); }