method2testcases
stringlengths
118
6.63k
### Question: RegularPriceCategory extends PriceCategory { @Override public double getCharge(int daysRented) { double result = 0; if (daysRented > 0) { result = 2; } if (daysRented > 2) { result = 2 + (daysRented - 2) * 1.5; } return result; } private RegularPriceCategory(); int getId(); @Override double getCharge(int...
### Question: RegularPriceCategory extends PriceCategory { @Override public String toString() { return "Regular"; } private RegularPriceCategory(); int getId(); @Override double getCharge(int daysRented); @Override String toString(); static RegularPriceCategory getInstance(); }### Answer: @Test public void testToStri...
### Question: Movie { @Override public int hashCode() { final int prime = 31; int result = prime + id; result = prime * result + ((releaseDate == null) ? 0 : releaseDate.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); return result; } protected Movie(); Movie(String aTitle, PriceCateg...
### Question: Movie { protected Movie() { } protected Movie(); Movie(String aTitle, PriceCategory aPriceCategory); Movie(String aTitle, Date aReleaseDate, PriceCategory aPriceCategory); PriceCategory getPriceCategory(); void setPriceCategory(PriceCategory aPriceCategory); String getTitle(); void setTitle(String aTit...
### Question: Movie { public void setTitle(String aTitle) { if (this.title != null) { throw new IllegalStateException(); } this.title = aTitle; } protected Movie(); Movie(String aTitle, PriceCategory aPriceCategory); Movie(String aTitle, Date aReleaseDate, PriceCategory aPriceCategory); PriceCategory getPriceCategor...
### Question: Movie { public void setReleaseDate(Date aReleaseDate) { if (this.releaseDate != null) { throw new IllegalStateException(); } this.releaseDate = aReleaseDate; } protected Movie(); Movie(String aTitle, PriceCategory aPriceCategory); Movie(String aTitle, Date aReleaseDate, PriceCategory aPriceCategory); P...
### Question: ChildrenPriceCategory extends PriceCategory { @Override public double getCharge(int daysRented) { double result = 0; if (daysRented > 0) { result = 1.5; if (daysRented > 3) { result += (daysRented - 3) * 1.5; } } return result; } private ChildrenPriceCategory(); int getId(); @Override double getCharge(in...
### Question: ChildrenPriceCategory extends PriceCategory { @Override public String toString() { return "Children"; } private ChildrenPriceCategory(); int getId(); @Override double getCharge(int daysRented); @Override String toString(); static ChildrenPriceCategory getInstance(); }### Answer: @Test public void testTo...
### Question: PriceCategory { public int getFrequentRenterPoints(int daysRented) { return daysRented > 0 ? 1 : 0; } int getId(); abstract double getCharge(int daysRented); int getFrequentRenterPoints(int daysRented); }### Answer: @Test public void testGetFrequentRenterPoints() { assertEquals(0, pc.getFrequentRenterPo...
### Question: Part04HandlingErrors { public Flux<Integer> errorIsTerminal(Flux<String> numbers) { return numbers.map(s -> Integer.parseInt(s)).log(); } Flux<Integer> errorIsTerminal(Flux<String> numbers); Flux<Integer> handleErrorWithFallback(Flux<String> numbers); Flux<Integer> handleErrorAndContinue(Flux<String> num...
### Question: Part04HandlingErrors { public Flux<Integer> handleErrorWithFallback(Flux<String> numbers) { return numbers.map(s -> Integer.parseInt(s)) .onErrorReturn(NumberFormatException.class, 0) .log(); } Flux<Integer> errorIsTerminal(Flux<String> numbers); Flux<Integer> handleErrorWithFallback(Flux<String> numbers...
### Question: Part04HandlingErrors { public Flux<Integer> handleErrorAndContinue(Flux<String> numbers) { return numbers.flatMap(s -> Mono.just(s).map(Integer::parseInt) .onErrorReturn(NumberFormatException.class, 0).log()); } Flux<Integer> errorIsTerminal(Flux<String> numbers); Flux<Integer> handleErrorWithFallback(Fl...
### Question: Part04HandlingErrors { public Flux<Integer> handleErrorWithEmptyMonoAndContinue(Flux<String> numbers) { return numbers.flatMap(s -> Mono.just(s).map(Integer::parseInt) .onErrorResume(throwable -> Mono.empty())).log(); } Flux<Integer> errorIsTerminal(Flux<String> numbers); Flux<Integer> handleErrorWithFal...
### Question: Part04HandlingErrors { public Flux<String> timeOutWithRetry(Flux<String> colors) { return colors.concatMap(color -> simulateRemoteCall(color) .timeout(Duration.ofMillis(400)) .doOnError(s -> log.info(s.getMessage())) .retry(2).onErrorReturn("default")).log(); } Flux<Integer> errorIsTerminal(Flux<String> ...
### Question: Part05Subscribe { public Flux<Integer> subscribeEmpty() { Flux<Integer> flux = Flux.just(1, 2, 3); flux.log().subscribe(); return flux; } Flux<Integer> subscribeEmpty(); Flux<Integer> subscribeWithConsumer(); Flux<Integer> subscribeWithConsumerAndCompleteConsumer(); Flux<Integer> subscribeWithConsumerAnd...
### Question: Part05Subscribe { public Flux<Integer> subscribeWithConsumer() { Flux<Integer> flux = Flux.just(1, 2, 3); flux.log().subscribe(integer -> log.info("{}", integer)); return flux; } Flux<Integer> subscribeEmpty(); Flux<Integer> subscribeWithConsumer(); Flux<Integer> subscribeWithConsumerAndCompleteConsumer(...
### Question: Part05Subscribe { public Flux<Integer> subscribeWithConsumerAndCompleteConsumer() { Flux<Integer> flux = Flux.just(1, 2, 3); flux.subscribe(integer -> log.info("{}", integer), null, () -> log.info("completed")); return flux; } Flux<Integer> subscribeEmpty(); Flux<Integer> subscribeWithConsumer(); Flux<In...
### Question: Part05Subscribe { public Flux<Integer> subscribeWithConsumerAndErrorConsumer() { Flux<Integer> flux = Flux.just(1, 2, 3, 4).map(i -> { if (i != 4) { return i; } else { throw new IllegalStateException("error"); } }); flux.log().subscribe(integer -> log.info("{}", integer), throwable -> log.info("{}", throw...
### Question: Part05Subscribe { public Flux<Integer> subscribeWithSubscriptionConsumer() { Flux<Integer> flux = Flux.just(1, 2, 3); flux.log().subscribe(null, null, null, new Consumer<Subscription>() { @Override public void accept(Subscription subscription) { subscription.request(2); } }); return flux; } Flux<Integer>...
### Question: Part05Subscribe { public Flux<Integer> subscribeWithSubscription() { Flux<Integer> flux = Flux.just(1, 2, 3); flux.log().subscribe(new Subscriber<Integer>() { Subscription s; @Override public void onSubscribe(Subscription s) { this.s = s; s.request(1); } @Override public void onNext(Integer integer) { s.r...
### Question: Part02Transform { Flux<Integer> transformToLength(Flux<String> flux) { return flux.map(s -> s.length()); } Flux<Tuple2<String, Integer>> pairValues(Flux<String> flux1, Flux<Integer> flux2); Mono<Order> combineValues(Mono<String> phoneNumber, Mono<String> deliveryAddress); }### Answer: @Test public void ...
### Question: Part02Transform { Flux<String> characters(Flux<String> flux) { return flux .map(s -> s.toUpperCase()) .flatMap(s -> Flux.fromArray(s.split("")).log()); } Flux<Tuple2<String, Integer>> pairValues(Flux<String> flux1, Flux<Integer> flux2); Mono<Order> combineValues(Mono<String> phoneNumber, Mono<String> del...
### Question: Part02Transform { Flux<String> combineInEmissionOrder(Flux<String> flux1, Flux<String> flux2) { return Flux.merge(flux1, flux2); } Flux<Tuple2<String, Integer>> pairValues(Flux<String> flux1, Flux<Integer> flux2); Mono<Order> combineValues(Mono<String> phoneNumber, Mono<String> deliveryAddress); }### An...
### Question: Part02Transform { public Flux<Tuple2<String, Integer>> pairValues(Flux<String> flux1, Flux<Integer> flux2) { return Flux.zip(flux1, flux2); } Flux<Tuple2<String, Integer>> pairValues(Flux<String> flux1, Flux<Integer> flux2); Mono<Order> combineValues(Mono<String> phoneNumber, Mono<String> deliveryAddress...
### Question: PRNGSeedFactoryBean implements FactoryBean<Integer> { @Override public Integer getObject() { try { int time = new java.util.Date().hashCode(); int ipAddress = InetAddress.getLocalHost().hashCode(); int rand = metaPrng.nextInt(); int seed = (ipAddress & 0xffff) | ((time & 0x00ff) << 32) | (rand & 0x0f00000...
### Question: RationalNumber { public void optimize() { int gcd = calcGcd(numerator, denominator); this.numerator = this.numerator / gcd; this.denominator = this.denominator / gcd; } RationalNumber(int numerator, int denominator); static RationalNumber create(int numerator, int denominator); int getNumerator(); int get...
### Question: RationalNumber { public static RationalNumber create(int numerator, int denominator) { return new RationalNumber(numerator, denominator); } RationalNumber(int numerator, int denominator); static RationalNumber create(int numerator, int denominator); int getNumerator(); int getDenominator(); void optimize(...
### Question: HumansJdbcTemplateDaoImpl implements HumansDao { @Override public Human find(int id) { try { return template.queryForObject(SQL_SELECT_USER_BY_ID, humanRowMapper, id); } catch (EmptyResultDataAccessException e) { throw new IllegalArgumentException("User with id <" + id + "> not found"); } } HumansJdbcTemp...
### Question: Validator { @VisibleForTesting void validateExactlyOnceSelect(SqlNodeList query) { Preconditions.checkArgument(query.size() > 0); SqlNode last = query.get(query.size() - 1); long n = StreamSupport.stream(query.spliterator(), false) .filter(x -> x instanceof SqlSelect) .count(); Preconditions.checkArgument...
### Question: JobWatcherUtil { static HealthCheckReport computeHealthCheckReport(Map<UUID, JobDefinition> jobs, Map<UUID, InstanceInfo> instances) { JobWatcherUtil.StateView v = JobWatcherUtil.computeState(jobs, instances); HealthCheckReport res = new HealthCheckReport(); for (Map.Entry<UUID, List<InstanceInfo>> e : v....
### Question: JobDeployer { void start(JobGraph job, JobConf desc) throws Exception { AthenaXYarnClusterDescriptor descriptor = new AthenaXYarnClusterDescriptor(clusterConf, yarnClient, flinkConf, desc); start(descriptor, job); } JobDeployer(YarnClusterConfiguration clusterConf, YarnClient yarnClient, Sch...
### Question: InstanceManager implements AutoCloseable { public void changeState(UUID uuid, InstanceState desiredState) throws IOException, YarnException { if (desiredState == null || desiredState.getState() != InstanceState.StateEnum.KILLED) { throw new UnsupportedOperationException(); } InstanceInfo info = instances(...
### Question: Validator { @VisibleForTesting void extract(SqlNodeList query) { for (SqlNode n : query) { if (n instanceof SqlSetOption) { extract((SqlSetOption) n); } else if (n instanceof SqlCreateFunction) { extract((SqlCreateFunction) n); } } } }### Answer: @Test(expected = IllegalArgumentException.class) public ...
### Question: Planner { @VisibleForTesting static SqlNodeList parse(String sql) throws ParseException { try (StringReader in = new StringReader(sql)) { SqlParserImpl impl = new SqlParserImpl(in); impl.switchTo("BTID"); impl.setTabSize(1); impl.setQuotedCasing(Lex.JAVA.quotedCasing); impl.setUnquotedCasing(Lex.JAVA.unqu...
### Question: KafkaUtils { static Properties getSubProperties(Map<String, String> prop, String prefix) { Properties p = new Properties(); for (Map.Entry<String, String> e : prop.entrySet()) { String key = e.getKey(); if (key.startsWith(prefix)) { p.put(key.substring(prefix.length()), e.getValue()); } } return p; } priv...
### Question: JobWatcherUtil { static StateView computeState(Map<UUID, JobDefinition> jobs, Map<UUID, InstanceInfo> instances) { HashMap<UUID, UUID> instanceToJob = new HashMap<>(); HashMap<UUID, List<InstanceInfo>> jobInstances = new HashMap<>(); for (Map.Entry<UUID, InstanceInfo> e : instances.entrySet()) { YarnAppli...
### Question: StatisticsQueue { public List<QueryStats> getReportSortedBy(String sortByVal) { SortBy sortBy; try { sortBy = SortBy.valueOf(sortByVal); } catch (Exception e) { throw new IllegalArgumentException("allowed values are: " + Arrays.toString(SortBy.values())); } List<QueryStats> res = new ArrayList<>(statsByQu...
### Question: Base { public static RowProcessor find(String query, Object ... params) { return new DB(DB.DEFAULT_NAME).find(query, params); } private Base(); static DB open(); static DB open(String driver, String url, String user, String password); static DB open(String driver, String url, Properties props); static DB...
### Question: Base { public static List<Map> findAll(String query, Object... params) { return new DB(DB.DEFAULT_NAME).findAll(query, params); } private Base(); static DB open(); static DB open(String driver, String url, String user, String password); static DB open(String driver, String url, Properties props); static ...
### Question: Base { public static int exec(String query){ return new DB(DB.DEFAULT_NAME).exec(query); } private Base(); static DB open(); static DB open(String driver, String url, String user, String password); static DB open(String driver, String url, Properties props); static DB open(String jndiName); static DB ope...
### Question: Base { public static Long count(String table) { return new DB(DB.DEFAULT_NAME).count(table); } private Base(); static DB open(); static DB open(String driver, String url, String user, String password); static DB open(String driver, String url, Properties props); static DB open(String jndiName); static DB...
### Question: DefaultDialect implements Dialect { @Override public String selectStar(String table) { return "SELECT * FROM " + table; } @Override String selectStar(String table); @Override String selectStar(String table, String where); @Override String selectStarParametrized(String table, String ... parameters); @Over...
### Question: DefaultDialect implements Dialect { @Override public String selectStarParametrized(String table, String ... parameters) { StringBuilder sql = new StringBuilder().append("SELECT * FROM ").append(table).append(" WHERE "); join(sql, parameters, " = ? AND "); sql.append(" = ?"); return sql.toString(); } @Ove...
### Question: DefaultDialect implements Dialect { @Override public String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId) { StringBuilder query = new StringBuilder().append("INSERT INTO ").append(metaModel.getTableName()).append(' '); if (columns.isEmpty()) { appendEmptyRow(metaModel, ...
### Question: DefaultDialect implements Dialect { @Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { LOGGER.error("ERROR!!!! Limit and Offset are not supported by DefaultDialect"); StringBuilder queryBuilder = new StringBuilder(); ap...
### Question: DefaultDialect implements Dialect { @Override public String selectManyToManyAssociation(Many2ManyAssociation association, String sourceFkColumnName, int questionsCount) { String targetTable = metaModelOf(association.getTargetClass()).getTableName(); StringBuilder query = new StringBuilder().append("SELECT...
### Question: DefaultDialect implements Dialect { @Override public String deleteManyToManyAssociation(Many2ManyAssociation association) { return "DELETE FROM " + association.getJoin() + " WHERE " + association.getSourceFkName() + " = ? AND " + association.getTargetFkName() + " = ?"; } @Override String selectStar(Strin...
### Question: DefaultDialect implements Dialect { @Override public String selectExists(MetaModel metaModel) { return "SELECT " + metaModel.getIdName() + " FROM " + metaModel.getTableName() + " WHERE " + metaModel.getIdName() + " = ?"; } @Override String selectStar(String table); @Override String selectStar(String tabl...
### Question: DefaultDialect implements Dialect { @Override public String insert(MetaModel metaModel, Map<String, Object> attributes, String ... replacements) { StringBuilder query = new StringBuilder().append("INSERT INTO ").append(metaModel.getTableName()).append(' '); if (attributes.isEmpty()) { appendEmptyRow(metaM...
### Question: DefaultDialect implements Dialect { @Override public String update(MetaModel metaModel, Map<String, Object> attributes, String ... replacements) { if (attributes.isEmpty()) { throw new NoSuchElementException("No attributes set, can't create an update statement."); } StringBuilder query = new StringBuilder...
### Question: PostgreSQLDialect extends DefaultDialect { @Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { StringBuilder fullQuery = new StringBuilder(); appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys); if(limi...
### Question: LazyList extends AbstractLazyList<T> implements Externalizable { public String toSql() { return toSql(true); } protected LazyList(String subQuery, MetaModel metaModel, Object... params); protected LazyList(boolean forPaginator, MetaModel metaModel, String fullQuery, Object... params); protected LazyLis...
### Question: Escape { public static void html(StringBuilder sb, String html) { for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case '\'': sb.append("&apos;"); break; case '<': sb.append("&lt;"); break; case '>': ...
### Question: Collections { public static <K, V> Map<K, V> map(Object... keysAndValues) { if (keysAndValues.length % 2 != 0) { throw new IllegalArgumentException("number of arguments must be even"); } Map<K, V> map = new HashMap<K, V>(Math.max(keysAndValues.length, 16)); for (int i = 0; i < keysAndValues.length;) { map...
### Question: Collections { public static <T> T[] array(T... values) { return values; } private Collections(); static T[] arr(T... values); static T[] array(T... values); static Set<T> set(T... values); static Map<K, V> map(Object... keysAndValues); static List<T> li(T... values); static List<T> list(T... values); }#...
### Question: Collections { public static <T> List<T> list(T... values) { return new ArrayList<T>(Arrays.asList(values)); } private Collections(); static T[] arr(T... values); static T[] array(T... values); static Set<T> set(T... values); static Map<K, V> map(Object... keysAndValues); static List<T> li(T... values); s...
### Question: Util { public static String join(String[] array, String delimiter) { if (empty(array)) { return ""; } StringBuilder sb = new StringBuilder(); join(sb, array, delimiter); return sb.toString(); } private Util(); static byte[] readResourceBytes(String resourceName); static String readResource(String resourc...
### Question: Util { public static String[] split(String input, String delimiters) { if (input == null) { throw new NullPointerException("input cannot be null"); } List<String> tokens = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(input, delimiters); while(st.hasMoreTokens()) { tokens.add(st.nextTo...
### Question: Util { public static byte[] bytes(InputStream in) throws IOException { if (in == null) { throw new IllegalArgumentException("input stream cannot be null"); } ByteArrayOutputStream os = null; try { os = new ByteArrayOutputStream(1024); byte[] bytes = new byte[1024]; int len; while ((len = in.read(bytes)) !...
### Question: Util { public static byte[] readResourceBytes(String resourceName) { InputStream is = Util.class.getResourceAsStream(resourceName); try { return bytes(is); } catch (IOException e) { throw new RuntimeException(e); } finally { closeQuietly(is); } } private Util(); static byte[] readResourceBytes(String res...
### Question: Util { public static String read(InputStream in) throws IOException { return read(in, "UTF-8"); } private Util(); static byte[] readResourceBytes(String resourceName); static String readResource(String resourceName); static String readResource(String resourceName, String charset); static String readFile(...
### Question: Util { public static String readResource(String resourceName) { return readResource(resourceName, "UTF-8"); } private Util(); static byte[] readResourceBytes(String resourceName); static String readResource(String resourceName); static String readResource(String resourceName, String charset); static Stri...
### Question: Util { public static boolean blank(Object value) { return value == null || value.toString().trim().length() == 0; } private Util(); static byte[] readResourceBytes(String resourceName); static String readResource(String resourceName); static String readResource(String resourceName, String charset); stati...
### Question: Util { public static boolean empty(Object[] array) { return array == null || array.length == 0; } private Util(); static byte[] readResourceBytes(String resourceName); static String readResource(String resourceName); static String readResource(String resourceName, String charset); static String readFile(...
### Question: Util { public static void repeat(StringBuilder sb, String str, int count) { for (int i = 0; i < count; i++) { sb.append(str); } } private Util(); static byte[] readResourceBytes(String resourceName); static String readResource(String resourceName); static String readResource(String resourceName, String c...
### Question: Util { public static void joinAndRepeat(StringBuilder sb, String str, String delimiter, int count) { if (count > 0) { sb.append(str); for (int i = 1; i < count; i++) { sb.append(delimiter); sb.append(str); } } } private Util(); static byte[] readResourceBytes(String resourceName); static String readResou...
### Question: Convert { public static BigDecimal toBigDecimal(Object value) { if (value == null) { return null; } else if (value instanceof BigDecimal) { return (BigDecimal) value; } else { try { return new BigDecimal(value.toString().trim()); } catch (NumberFormatException e) { throw new ConversionException("failed to...
### Question: Convert { public static Long toLong(Object value) { if (value == null) { return null; } else if (value instanceof Long) { return (Long) value; } else if (value instanceof Number) { return ((Number) value).longValue(); } else if (value instanceof java.util.Date) { return ((java.util.Date) value).getTime();...
### Question: Convert { public static Double toDouble(Object value) { if (value == null) { return null; } else if (value instanceof Double) { return (Double) value; } else if (value instanceof Number) { return ((Number) value).doubleValue(); } else { try { return Double.valueOf(value.toString().trim()); } catch (Number...
### Question: Convert { public static Float toFloat(Object value) { if (value == null) { return null; } else if (value instanceof Float) { return (Float) value; } else if (value instanceof Number) { return ((Number) value).floatValue(); } else { return Float.valueOf(value.toString().trim()); } } private Convert(); sta...
### Question: Convert { public static Short toShort(Object value) { if (value == null) { return null; } else if (value instanceof Short) { return (Short) value; } else if (value instanceof Number) { return ((Number) value).shortValue(); } else { try { return Short.valueOf(value.toString().trim()); } catch (NumberFormat...
### Question: Convert { public static Boolean toBoolean(Object value) { if (value == null) { return false; } else if (value instanceof Boolean) { return (Boolean) value; } else if (value instanceof BigDecimal) { return value.equals(BigDecimal.ONE); } else if (value instanceof Number) { return ((Number) value).intValue(...
### Question: Convert { public static String toIsoString(java.util.Date date) { if (date == null) { return null; } else if (date instanceof java.sql.Date) { return date.toString(); } Calendar cal = THREADLOCAL_CAL_UTC.get(); cal.setTime(date); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; ...
### Question: Convert { public static byte[] toBytes(Object value) { if (value == null) { return null; } else if (value instanceof byte[]) { return (byte[]) value; } else if (value instanceof Blob) { return toBytes((Blob) value); } else { return toString(value).getBytes(); } } private Convert(); static String toString...
### Question: TomcatVersionValidator extends ValidatorBase implements IConstants, IConfigKeys { public static String getTomcatVersion(String serverInfo) { String result = null; if (serverInfo != null && !serverInfo.isEmpty()) { Debug.log("TomcatVersionValidator.getTomcatVersion() - validating ServerInfo:" + serverInfo)...
### Question: XPathResolver implements LogicalSourceResolver<XdmItem> { @Override public ExpressionEvaluatorFactory<XdmItem> getExpressionEvaluatorFactory() { return entry -> expression -> { try { XPathSelector selector = xpath.compile(expression).load(); selector.setContextItem(entry); XdmValue value = selector.evalua...
### Question: CarmlMapper implements Mapper, MappingCache { @Override public <T> T map(Model model, Resource resource, Set<Type> types) { if (types.size() > 1) { if (!types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { throw new IllegalStateException(String.format( "Error mapping %s. In case of multiple types,...
### Question: IriSafeMaker implements Function<String, String> { @Override public String apply(String s) { StringBuilder result = new StringBuilder(); s = Normalizer.normalize(s, normalizationForm); s.codePoints().flatMap(c -> { if ( Character.isAlphabetic(c) || Character.isDigit(c) || c == '-' || c == '.' || c == '_' ...
### Question: TermGeneratorCreator { @SuppressWarnings("unchecked") TermGenerator<Value> getObjectGenerator(ObjectMap map) { return (TermGenerator<Value>) getGenerator( map, ImmutableSet.of(TermType.IRI, TermType.BLANK_NODE, TermType.LITERAL), ImmutableSet.of(IRI.class, Literal.class) ); } TermGeneratorCreator( Value...
### Question: ParentTriplesMapper { Set<Resource> map(Set<Pair<String, Object>> joinValues) { if (joinValues.isEmpty()) { return ImmutableSet.of(); } Set<Resource> results = new LinkedHashSet<>(); getIterator.get().forEach(e -> map(e, joinValues) .forEach(results::add)); return results; } ParentTriplesMapper( TermGen...
### Question: RmlMapper { public Model map(Set<TriplesMap> mapping) { validateMapping(mapping); Model model = new LinkedHashModel(); Set<TriplesMap> functionValueTriplesMaps = getTermMaps(mapping) .filter(t -> t.getFunctionValue() != null) .map(TermMap::getFunctionValue) .collect(ImmutableCollectors.toImmutableSet()); ...
### Question: GetTemplateValue implements Function<EvaluateExpression, Optional<Object>> { @Override public Optional<Object> apply(EvaluateExpression evaluateExpression) { if (LOG.isTraceEnabled()) { LOG.trace("Processing template: {}", template.toTemplateString()); } Template.Builder templateBuilder = template.newBuil...
### Question: CsvResolver implements LogicalSourceResolver<Record> { @Override public ExpressionEvaluatorFactory<Record> getExpressionEvaluatorFactory() { return entry -> expression -> { logEvaluateExpression(expression, LOG); return Optional.ofNullable(entry.getString(expression)); }; } @Override SourceIterator<Recor...
### Question: QueryUtils { public static Model getModelFromRepo(Repository repository, String sparqlQuery) { Objects.requireNonNull(repository, REPOSITORY_MSG); Objects.requireNonNull(repository, SPARQL_QUERY_MSG); return Repositories.graphQuery( repository, sparqlQuery, QueryResults::asModel ); } private QueryUtils()...
### Question: Offsets { public static Offset at(HorizontalOffset horizontal, VerticalOffset vertical) { return new InternalOffsets.OffsetImpl(horizontal, vertical); } static Offset at(HorizontalOffset horizontal, VerticalOffset vertical); static Offset at(String pos); }### Answer: @Test public void testParseOk() { Of...
### Question: HelloDocker { @GET public static String hello() { return "Hello world!"; } @GET static String hello(); static void main(String[] args); }### Answer: @Test public void testHello() { assertEquals("Hello world!", target("/").request().get(String.class)); }
### Question: MinijaxPersistenceUnitInfo implements javax.persistence.spi.PersistenceUnitInfo { @Override public SharedCacheMode getSharedCacheMode() { throw new UnsupportedOperationException(); } MinijaxPersistenceUnitInfo(final String name, final String providerClassName); @Override String getPersistenceUnitName(); @...
### Question: MinijaxPersistenceUnitInfo implements javax.persistence.spi.PersistenceUnitInfo { @Override public ValidationMode getValidationMode() { throw new UnsupportedOperationException(); } MinijaxPersistenceUnitInfo(final String name, final String providerClassName); @Override String getPersistenceUnitName(); @Ov...
### Question: MinijaxPersistenceUnitInfo implements javax.persistence.spi.PersistenceUnitInfo { @Override public String getPersistenceXMLSchemaVersion() { throw new UnsupportedOperationException(); } MinijaxPersistenceUnitInfo(final String name, final String providerClassName); @Override String getPersistenceUnitName()...
### Question: MinijaxPersistenceUnitInfo implements javax.persistence.spi.PersistenceUnitInfo { @Override public ClassLoader getClassLoader() { throw new UnsupportedOperationException(); } MinijaxPersistenceUnitInfo(final String name, final String providerClassName); @Override String getPersistenceUnitName(); @Override...
### Question: MinijaxPersistenceUnitInfo implements javax.persistence.spi.PersistenceUnitInfo { @Override public void addTransformer(final ClassTransformer transformer) { throw new UnsupportedOperationException(); } MinijaxPersistenceUnitInfo(final String name, final String providerClassName); @Override String getPersi...
### Question: MinijaxPersistenceUnitInfo implements javax.persistence.spi.PersistenceUnitInfo { @Override public ClassLoader getNewTempClassLoader() { throw new UnsupportedOperationException(); } MinijaxPersistenceUnitInfo(final String name, final String providerClassName); @Override String getPersistenceUnitName(); @O...
### Question: Parser { private MinijaxCriteriaQuery<T> parseSelect() { consume(TokenType.KEYWORD_SELECT); query = cb.createQuery(resultType); while (getCurr().getTokenType() != TokenType.KEYWORD_FROM) { index++; } consume(TokenType.KEYWORD_FROM); final MinijaxEntityType<T> resultEntityType = cb.getMetamodel().entity(re...
### Question: Parser { public static <T> MinijaxCriteriaQuery<T> parse(final MinijaxCriteriaBuilder cb, final Class<T> resultType, final List<Token> tokens) { return new Parser<>(cb, resultType, tokens).parse(); } private Parser(final MinijaxCriteriaBuilder cb, final Class<T> resultType, final List<Token> tokens); sta...
### Question: Hello { @GET public static String hello() { return "Hello world!"; } @GET static String hello(); static void main(String[] args); }### Answer: @Test public void testHello() { assertEquals("Hello world!", target("/").request().get(String.class)); }
### Question: Parser { private void parseOrderBy() { consume(TokenType.KEYWORD_ORDER); consume(TokenType.KEYWORD_BY); final MinijaxPath<?> path = parsePath(); boolean ascending = true; if (index < tokens.size()) { final Token curr = getCurr(); if (curr.getTokenType() == TokenType.KEYWORD_ASC) { consume(TokenType.KEYWOR...
### Question: Tokenizer { public static List<Token> tokenize(final String str) { return new Tokenizer(str).tokenize(); } private Tokenizer(final String str); static List<Token> tokenize(final String str); }### Answer: @Test public void testSelectByVariable() { final List<Token> tokens = Tokenizer.tokenize("SELECT w F...
### Question: App { @GET @Path("/") public static String hello() { return "Hello world!"; } @GET @Path("/") static String hello(); static void main(final String[] args); }### Answer: @Test public void testHello() { assertEquals("Hello world!", target("/").request().get(String.class)); }
### Question: MinijaxEntityManagerFactory implements javax.persistence.EntityManagerFactory, AutoCloseable { @Override public MinijaxEntityManager createEntityManager() { return new MinijaxEntityManager(this, metamodel, dialect, createConnection()); } @SuppressWarnings({ "unchecked", "rawtypes" }) MinijaxEntityManager...
### Question: MinijaxEntityManagerFactory implements javax.persistence.EntityManagerFactory, AutoCloseable { @Override public CriteriaBuilder getCriteriaBuilder() { throw new UnsupportedOperationException(); } @SuppressWarnings({ "unchecked", "rawtypes" }) MinijaxEntityManagerFactory(final MinijaxPersistenceUnitInfo u...