use of org.apache.samza.table.remote.TableRateLimiter.CreditFunction in project samza by apache.
the class TestRemoteTableDescriptor method testTablePartToConfig.
@Test
public void testTablePartToConfig() {
int key = 0;
TableReadFunction readFn = createMockTableReadFunction();
when(readFn.toConfig(any(), any())).thenReturn(createConfigPair(key));
TableWriteFunction writeFn = createMockTableWriteFunction();
when(writeFn.toConfig(any(), any())).thenReturn(createConfigPair(key));
RateLimiter rateLimiter = createMockRateLimiter();
when(((TablePart) rateLimiter).toConfig(any(), any())).thenReturn(createConfigPair(key));
CreditFunction readCredFn = createMockCreditFunction();
when(readCredFn.toConfig(any(), any())).thenReturn(createConfigPair(key));
CreditFunction writeCredFn = createMockCreditFunction();
when(writeCredFn.toConfig(any(), any())).thenReturn(createConfigPair(key));
TableRetryPolicy readRetryPolicy = createMockTableRetryPolicy();
when(readRetryPolicy.toConfig(any(), any())).thenReturn(createConfigPair(key));
TableRetryPolicy writeRetryPolicy = createMockTableRetryPolicy();
when(writeRetryPolicy.toConfig(any(), any())).thenReturn(createConfigPair(key));
Map<String, String> tableConfig = new RemoteTableDescriptor("1").withReadFunction(readFn).withWriteFunction(writeFn).withRateLimiter(rateLimiter, readCredFn, writeCredFn).withReadRetryPolicy(readRetryPolicy).withWriteRetryPolicy(writeRetryPolicy).toConfig(new MapConfig());
verify(readFn, times(1)).toConfig(any(), any());
verify(writeFn, times(1)).toConfig(any(), any());
verify((TablePart) rateLimiter, times(1)).toConfig(any(), any());
verify(readCredFn, times(1)).toConfig(any(), any());
verify(writeCredFn, times(1)).toConfig(any(), any());
verify(readRetryPolicy, times(1)).toConfig(any(), any());
verify(writeRetryPolicy, times(1)).toConfig(any(), any());
Assert.assertEquals(tableConfig.get("tables.1.io.read.func.k0"), "v0");
Assert.assertEquals(tableConfig.get("tables.1.io.write.func.k0"), "v0");
Assert.assertEquals(tableConfig.get("tables.1.io.ratelimiter.k0"), "v0");
Assert.assertEquals(tableConfig.get("tables.1.io.read.credit.func.k0"), "v0");
Assert.assertEquals(tableConfig.get("tables.1.io.write.credit.func.k0"), "v0");
Assert.assertEquals(tableConfig.get("tables.1.io.read.retry.policy.k0"), "v0");
Assert.assertEquals(tableConfig.get("tables.1.io.write.retry.policy.k0"), "v0");
}
Aggregations