use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripDaoTest method testGetFishingTripIdsForMatchingFilterCriteria_allCommonFilters.
@Test
@SneakyThrows
public void testGetFishingTripIdsForMatchingFilterCriteria_allCommonFilters() throws Exception {
dbSetupTracker.skipNextLaunch();
Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
searchCriteriaMap.put(SearchFilter.ACTIVITY_TYPE, "DEPARTURE");
searchCriteriaMap.put(SearchFilter.SOURCE, "FLUX");
searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
searchCriteriaMap.put(SearchFilter.FROM, "OWNER1");
searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27T07:47:31");
searchCriteriaMap.put(SearchFilter.PERIOD_END, "2018-05-27T07:47:31");
searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
searchCriteriaMap.put(SearchFilter.AREAS, "J");
searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");
searchCriteriaMap.put(SearchFilter.SPECIES, "BFT");
searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "50");
searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
Map<SearchFilter, List<String>> searchCriteriaMapMultiVal = new HashMap<>();
List<String> purposeCodeValues = new ArrayList<>();
purposeCodeValues.add("9");
purposeCodeValues.add("1");
purposeCodeValues.add("5");
purposeCodeValues.add("3");
FishingActivityQuery query = new FishingActivityQuery();
query.setSearchCriteriaMap(searchCriteriaMap);
query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultiVal);
searchCriteriaMapMultiVal.put(SearchFilter.PURPOSE, purposeCodeValues);
Set<FishingTripId> fishingTripIdSet = dao.getFishingTripIdsForMatchingFilterCriteria(query);
FishingTripId fishingTripId = new FishingTripId("NOR-TRP-20160517234053706", "EU_TRIP_ID");
assertEquals(true, fishingTripIdSet.contains(fishingTripId));
assertNotNull(fishingTripIdSet);
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityConfigServiceBean method saveUserConfig.
@Override
@SneakyThrows
public /**
* {@inheritDoc}
*/
String saveUserConfig(ActivityConfigDTO updatedConfig, String userConfig) throws ServiceException {
ActivityConfigDTO usmUserConfig = getConfiguration(userConfig);
ActivityConfigDTO mergedConfig = PreferenceConfigMapper.INSTANCE.mergeUserPreference(usmUserConfig, updatedConfig);
return getJson(mergedConfig);
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class JacksonSubclassSerializerTest method testSerializing.
@SneakyThrows
@Test
public void testSerializing() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
FishingActivityQuery fishQuery = new FishingActivityQuery();
Map<SearchFilter, String> map = new HashMap<>();
String val = "someVal";
map.put(SearchFilter.VESSEL, val);
fishQuery.setSearchCriteriaMap(map);
String s = null;
try {
s = mapper.writeValueAsString(fishQuery);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
System.out.println(s);
}
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 bookkeeper by apache.
the class ZKMetadataDriverBase method initialize.
@SneakyThrows(InterruptedException.class)
protected void initialize(AbstractConfiguration<?> conf, StatsLogger statsLogger, RetryPolicy zkRetryPolicy, Optional<Object> optionalCtx) throws MetadataException {
this.conf = conf;
this.acls = ZkUtils.getACLs(conf);
if (optionalCtx.isPresent() && optionalCtx.get() instanceof ZooKeeper) {
this.ledgersRootPath = conf.getZkLedgersRootPath();
log.info("Initialize zookeeper metadata driver with external zookeeper client : ledgersRootPath = {}.", ledgersRootPath);
// if an external zookeeper is added, use the zookeeper instance
this.zk = (ZooKeeper) (optionalCtx.get());
this.ownZKHandle = false;
} else {
final String metadataServiceUriStr;
try {
metadataServiceUriStr = conf.getMetadataServiceUri();
} catch (ConfigurationException e) {
log.error("Failed to retrieve metadata service uri from configuration", e);
throw new MetadataException(Code.INVALID_METADATA_SERVICE_URI, e);
}
URI metadataServiceUri = URI.create(metadataServiceUriStr);
// get the initialize root path
this.ledgersRootPath = metadataServiceUri.getPath();
final String bookieRegistrationPath = ledgersRootPath + "/" + AVAILABLE_NODE;
final String bookieReadonlyRegistrationPath = bookieRegistrationPath + "/" + READONLY;
// construct the zookeeper
final String zkServers = getZKServersFromServiceUri(metadataServiceUri);
log.info("Initialize zookeeper metadata driver at metadata service uri {} :" + " zkServers = {}, ledgersRootPath = {}.", metadataServiceUriStr, zkServers, ledgersRootPath);
try {
this.zk = ZooKeeperClient.newBuilder().connectString(zkServers).sessionTimeoutMs(conf.getZkTimeout()).operationRetryPolicy(zkRetryPolicy).requestRateLimit(conf.getZkRequestRateLimit()).statsLogger(statsLogger).build();
if (null == zk.exists(bookieReadonlyRegistrationPath, false)) {
try {
zk.create(bookieReadonlyRegistrationPath, EMPTY_BYTE_ARRAY, acls, CreateMode.PERSISTENT);
} catch (KeeperException.NodeExistsException e) {
// this node is just now created by someone.
} catch (KeeperException.NoNodeException e) {
// the cluster hasn't been initialized
}
}
} catch (IOException | KeeperException e) {
log.error("Failed to create zookeeper client to {}", zkServers, e);
MetadataException me = new MetadataException(Code.METADATA_SERVICE_ERROR, "Failed to create zookeeper client to " + zkServers, e);
me.fillInStackTrace();
throw me;
}
this.ownZKHandle = true;
}
// once created the zookeeper client, create the layout manager and registration client
this.layoutManager = new ZkLayoutManager(zk, ledgersRootPath, acls);
}
Aggregations