use of org.apache.curator.framework.api.SetDataBuilder in project metron by apache.
the class GlobalConfigServiceImplTest method saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave.
@Test
public void saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave() throws Exception {
SetDataBuilder setDataBuilder = mock(SetDataBuilder.class);
when(setDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot(), "{ }".getBytes(StandardCharsets.UTF_8))).thenReturn(new Stat());
when(curatorFramework.setData()).thenReturn(setDataBuilder);
assertEquals(new HashMap<>(), globalConfigService.save(new HashMap<>()));
verify(setDataBuilder).forPath(eq(ConfigurationType.GLOBAL.getZookeeperRoot()), eq("{ }".getBytes(StandardCharsets.UTF_8)));
}
use of org.apache.curator.framework.api.SetDataBuilder in project metron by apache.
the class GlobalConfigServiceImplTest method saveShouldWrapExceptionInRestException.
@Test
public void saveShouldWrapExceptionInRestException() throws Exception {
SetDataBuilder setDataBuilder = mock(SetDataBuilder.class);
when(setDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot(), "{ }".getBytes(StandardCharsets.UTF_8))).thenThrow(Exception.class);
when(curatorFramework.setData()).thenReturn(setDataBuilder);
assertThrows(RestException.class, () -> globalConfigService.save(new HashMap<>()));
}
use of org.apache.curator.framework.api.SetDataBuilder in project metron by apache.
the class SensorIndexingConfigServiceImplTest method saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave.
@Test
public void saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave() throws Exception {
final Map<String, Object> sensorIndexingConfig = getTestSensorIndexingConfig();
when(objectMapper.writeValueAsString(sensorIndexingConfig)).thenReturn(broJson);
SetDataBuilder setDataBuilder = mock(SetDataBuilder.class);
when(setDataBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro", broJson.getBytes(StandardCharsets.UTF_8))).thenReturn(new Stat());
when(curatorFramework.setData()).thenReturn(setDataBuilder);
assertEquals(sensorIndexingConfig, sensorIndexingConfigService.save("bro", sensorIndexingConfig));
verify(setDataBuilder).forPath(eq(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro"), eq(broJson.getBytes(StandardCharsets.UTF_8)));
}
use of org.apache.curator.framework.api.SetDataBuilder in project metron by apache.
the class SensorParserConfigServiceImplTest method saveShouldWrapExceptionInRestException.
@Test
public void saveShouldWrapExceptionInRestException() throws Exception {
SetDataBuilder setDataBuilder = mock(SetDataBuilder.class);
when(setDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro", broJson.getBytes(StandardCharsets.UTF_8))).thenThrow(Exception.class);
when(curatorFramework.setData()).thenReturn(setDataBuilder);
final SensorParserConfig sensorParserConfig = new SensorParserConfig();
sensorParserConfig.setSensorTopic("bro");
assertThrows(RestException.class, () -> sensorParserConfigService.save("bro", sensorParserConfig));
}
Aggregations