use of lombok.SneakyThrows in project LogisticsPipes by RS485.
the class PacketHandler method initialize.
/*
* enumerates all ModernPackets, sets their IDs and populate packetlist/packetmap
*/
@SuppressWarnings("unchecked")
@SneakyThrows({ IOException.class, InvocationTargetException.class, IllegalAccessException.class, InstantiationException.class, IllegalArgumentException.class, NoSuchMethodException.class, SecurityException.class })
public static final // Suppression+sneakiness because these shouldn't ever fail, and if they do, it needs to fail.
void initialize() {
final List<ClassInfo> classes = new ArrayList<>(ClassPath.from(PacketHandler.class.getClassLoader()).getTopLevelClassesRecursive("logisticspipes.network.packets"));
Collections.sort(classes, (o1, o2) -> o1.getSimpleName().compareTo(o2.getSimpleName()));
PacketHandler.packetlist = new ArrayList<>(classes.size());
PacketHandler.packetmap = new HashMap<>(classes.size());
int currentid = 0;
for (ClassInfo c : classes) {
final Class<?> cls = c.load();
final ModernPacket instance = (ModernPacket) cls.getConstructor(int.class).newInstance(currentid);
PacketHandler.packetlist.add(instance);
PacketHandler.packetmap.put((Class<? extends ModernPacket>) cls, instance);
currentid++;
}
}
use of lombok.SneakyThrows in project LogisticsPipes by RS485.
the class LPBCTileGenericPipe method updateEntity_LP.
@Override
@SneakyThrows({ NoSuchFieldException.class, SecurityException.class, IllegalArgumentException.class, IllegalAccessException.class, NoSuchMethodException.class, InvocationTargetException.class })
public void updateEntity_LP() {
//Make sure we still have the same TE values
xCoord = lpPipe.xCoord;
yCoord = lpPipe.yCoord;
zCoord = lpPipe.zCoord;
if (attachPluggables) {
attachPluggables = false;
// Attach callback
PipePluggable[] pluggables = ReflectionHelper.getPrivateField(PipePluggable[].class, SideProperties.class, "pluggables", sideProperties);
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
if (pluggables[i] != null) {
pipe.eventBus.registerHandler(pluggables[i]);
pluggables[i].onAttachedPipe(this, ForgeDirection.getOrientation(i));
}
}
notifyBlockChanged();
}
if (!BlockGenericPipe.isValid(pipe)) {
return;
}
pipe.updateEntity();
boolean recheckThisPipe = false;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
PipePluggable p = getPipePluggable(direction);
if (p != null) {
p.update(this, direction);
//Check Gate for ActionChanges
if (p instanceof GatePluggable && lpPipe.isRoutingPipe()) {
if (!activeActions.containsKey(direction)) {
activeActions.put(direction, new ArrayList<>());
}
if (!listEquals(activeActions.get(direction), pipe.gates[direction.ordinal()].activeActions)) {
activeActions.get(direction).clear();
activeActions.get(direction).addAll(pipe.gates[direction.ordinal()].activeActions);
lpPipe.getRoutingPipe().triggerConnectionCheck();
recheckThisPipe = true;
}
} else if (activeActions.containsKey(direction)) {
activeActions.remove(direction);
}
if (p instanceof RobotStationPluggable) {
if (((RobotStationPluggable) p).getStation() != null && ((RobotStationPluggable) p).getStation().robotTaking() != null && ((RobotStationPluggable) p).getStation().robotTaking().getBoard() instanceof LogisticsRoutingBoardRobot) {
((RobotStationPluggable) p).getStation().robotTaking().getBoard().cycle();
}
}
}
}
if (recheckThisPipe) {
LPRobotConnectionControl.instance.checkAll(worldObj);
}
if (worldObj.isRemote) {
if (resyncGateExpansions) {
ReflectionHelper.invokePrivateMethod(Object.class, TileGenericPipe.class, this, "syncGateExpansions", new Class[] {}, new Object[] {});
}
return;
}
if (blockNeighborChange) {
//ReflectionHelper.invokePrivateMethod(Object.class, TileGenericPipe.class, this, "computeConnections", new Class[]{}, new Object[]{});
pipe.onNeighborBlockChange(0);
blockNeighborChange = false;
refreshRenderState = true;
}
if (refreshRenderState) {
refreshRenderState();
refreshRenderState = false;
}
}
use of lombok.SneakyThrows in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogModelTest method testDataEnrichment.
@Test
@SneakyThrows
public void testDataEnrichment() {
Mockito.when(logDao.getExchangeLogListSearchCount(Mockito.anyString(), Mockito.anyList())).thenReturn(100L);
Mockito.when(logDao.getExchangeLogListPaginated(Mockito.any(Integer.class), Mockito.any(Integer.class), Mockito.anyString(), Mockito.anyList())).thenReturn(logs);
Mockito.when(logDao.getExchangeLogByRangeOfRefGuids(Mockito.anyList())).thenReturn(refLogs);
ExchangeListQuery query = new ExchangeListQuery();
ExchangeListPagination pagin = new ExchangeListPagination();
ExchangeListCriteria exchCrit = new ExchangeListCriteria();
query.setPagination(pagin);
pagin.setListSize(10);
query.setExchangeSearchCriteria(exchCrit);
ListResponseDto exchangeLogListByQuery = exchangeLogModel.getExchangeLogListByQuery(query);
List<ExchangeLogType> exchangeLogList = exchangeLogListByQuery.getExchangeLogList();
ExchangeLogType exchangeLogType1 = exchangeLogList.get(0);
ExchangeLogType exchangeLogType2 = exchangeLogList.get(1);
assertTrue(exchangeLogType1.getRelatedLogData().isEmpty());
assertTrue(!exchangeLogType2.getRelatedLogData().isEmpty());
System.out.println("Done");
}
use of lombok.SneakyThrows in project cas by apereo.
the class CasRestAuthenticationConfiguration method restAuthenticationTemplate.
@Bean
@RefreshScope
@SneakyThrows
public RestTemplate restAuthenticationTemplate() {
final URI casHost = new URI(casProperties.getServer().getName());
final HttpHost host = new HttpHost(casHost.getHost(), casHost.getPort(), casHost.getScheme());
final ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host);
return new RestTemplate(factory);
}
use of lombok.SneakyThrows in project cas by apereo.
the class RestServiceRegistryConfiguration method restfulServiceRegistry.
@Bean
@RefreshScope
@SneakyThrows
public ServiceRegistry restfulServiceRegistry() {
final ServiceRegistryProperties registry = casProperties.getServiceRegistry();
final RestTemplate restTemplate = new RestTemplate();
final MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
if (StringUtils.isNotBlank(registry.getRest().getBasicAuthUsername()) && StringUtils.isNotBlank(registry.getRest().getBasicAuthPassword())) {
final String auth = registry.getRest().getBasicAuthUsername() + ":" + registry.getRest().getBasicAuthPassword();
final byte[] encodedAuth = EncodingUtils.encodeBase64ToByteArray(auth.getBytes(StandardCharsets.UTF_8));
final String authHeader = "Basic " + new String(encodedAuth, StandardCharsets.UTF_8);
headers.put("Authorization", CollectionUtils.wrap(authHeader));
}
return new RestServiceRegistry(restTemplate, registry.getRest().getUrl(), headers);
}
Aggregations