/** * The mapper should execute the 'groupBy' Stellar expressions and use that to generate a row key. */ @Test public void testExecuteGroupBy() throws Exception { // setup - expression that refers to the ProfileMeasurement.end measurement.setGroupBy(Arrays.asList("2 + 2")); // execute mapper.rowKey(tuple); // capture the ProfileMeasurement that should be emitted ArgumentCaptor<List> arg = ArgumentCaptor.forClass(List.class); verify(rowKeyBuilder).rowKey(any(), arg.capture()); // validate List<Object> actual = arg.getValue(); Assert.assertEquals(4.0, actual.get(0)); }
@Before public void setup() { executor = new DefaultStellarExecutor(); rowKeyBuilder = mock(RowKeyBuilder.class); mapper = new ProfileHBaseMapper(); mapper.setExecutor(executor); mapper.setRowKeyBuilder(rowKeyBuilder); measurement = new ProfileMeasurement("profile", "entity", 20000, 15, TimeUnit.MINUTES); measurement.setValue(22); profile = new ProfileConfig(); // the tuple will contain the original message tuple = mock(Tuple.class); when(tuple.getValueByField(eq("measurement"))).thenReturn(measurement); when(tuple.getValueByField(eq("profile"))).thenReturn(profile); }