use of com.linkedin.d2.backuprequests.BoundedCostBackupRequestsStrategy in project rest.li by linkedin.
the class TestBackupRequestsStrategyFactory method testBoundedCostBackupRequestsDeser.
@Test
public void testBoundedCostBackupRequestsDeser() throws IOException {
BackupRequestsConfiguration brc = new BackupRequestsConfiguration();
BoundedCostBackupRequests bcbr = new BoundedCostBackupRequests();
bcbr.setCost(3);
bcbr.setHistoryLength(4096);
bcbr.setMaxBurst(16);
bcbr.setMinBackupDelayMs(5);
bcbr.setRequiredHistoryLength(65536);
brc.setOperation("BATCH_GET");
brc.setStrategy(BackupRequestsConfiguration.Strategy.create(bcbr));
String json = new JacksonDataCodec().mapToString(brc.data());
@SuppressWarnings("unchecked") Map<String, Object> map = JacksonUtil.getObjectMapper().readValue(json, Map.class);
BackupRequestsStrategy strategy = BackupRequestsStrategyFactory.tryCreate(map);
assertNotNull(strategy);
assertTrue(strategy instanceof BoundedCostBackupRequestsStrategy);
BoundedCostBackupRequestsStrategy boundedCostStrategy = (BoundedCostBackupRequestsStrategy) strategy;
assertEquals(boundedCostStrategy.getHistoryLength(), (int) bcbr.getHistoryLength());
assertEquals(boundedCostStrategy.getMinBackupDelayNano(), (long) bcbr.getMinBackupDelayMs() * 1000L * 1000L);
assertEquals(boundedCostStrategy.getRequiredHistory(), (int) bcbr.getRequiredHistoryLength());
assertEquals(boundedCostStrategy.getPercent(), (double) bcbr.getCost());
}
Aggregations