Search in sources :

Example 1 with SneakyThrows

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++;
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) ArrayList(java.util.ArrayList) ClassInfo(com.google.common.reflect.ClassPath.ClassInfo) SneakyThrows(lombok.SneakyThrows)

Example 2 with SneakyThrows

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;
    }
}
Also used : RobotStationPluggable(buildcraft.robotics.RobotStationPluggable) LogisticsRoutingBoardRobot(logisticspipes.proxy.buildcraft.robots.boards.LogisticsRoutingBoardRobot) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) GatePluggable(buildcraft.transport.gates.GatePluggable) SneakyThrows(lombok.SneakyThrows)

Example 3 with SneakyThrows

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");
}
Also used : ExchangeListCriteria(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeListCriteria) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeListQuery(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeListQuery) ExchangeListPagination(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeListPagination) ListResponseDto(eu.europa.ec.fisheries.uvms.exchange.model.dto.ListResponseDto) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 4 with SneakyThrows

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);
}
Also used : ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) HttpHost(org.apache.http.HttpHost) RestTemplate(org.springframework.web.client.RestTemplate) URI(java.net.URI) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) SneakyThrows(lombok.SneakyThrows) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with SneakyThrows

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);
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ServiceRegistryProperties(org.apereo.cas.configuration.model.core.services.ServiceRegistryProperties) RestTemplate(org.springframework.web.client.RestTemplate) RestServiceRegistry(org.apereo.cas.services.RestServiceRegistry) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) SneakyThrows(lombok.SneakyThrows) Bean(org.springframework.context.annotation.Bean)

Aggregations

SneakyThrows (lombok.SneakyThrows)687 lombok.val (lombok.val)313 Test (org.junit.Test)87 ArrayList (java.util.ArrayList)73 HashMap (java.util.HashMap)61 List (java.util.List)52 Cleanup (lombok.Cleanup)38 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 Map (java.util.Map)32 Collectors (java.util.stream.Collectors)32 LinkedHashMap (java.util.LinkedHashMap)29 File (java.io.File)27 Path (java.nio.file.Path)27 IOException (java.io.IOException)26 InputStream (java.io.InputStream)24 Slf4j (lombok.extern.slf4j.Slf4j)24 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 URL (java.net.URL)21 Collection (java.util.Collection)18 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)16