method2testcases
stringlengths
118
3.08k
### Question: DefaultValidator extends AbstractValidator { @Override public Validator add(Message message) { message.setBundle(bundle); messages.add(message); return this; } protected DefaultValidator(); @Inject DefaultValidator(Result result, ValidationViewsFactory factory, Outjector outjector, Proxifier proxifier, ...
### Question: DefaultValidator extends AbstractValidator { @Override public List<Message> getErrors() { return messages.getErrors(); } protected DefaultValidator(); @Inject DefaultValidator(Result result, ValidationViewsFactory factory, Outjector outjector, Proxifier proxifier, ResourceBundle bundle, javax.valida...
### Question: DefaultValidator extends AbstractValidator { @Override public Validator addAll(Collection<? extends Message> messages) { for (Message message : messages) { add(message); } return this; } protected DefaultValidator(); @Inject DefaultValidator(Result result, ValidationViewsFactory factory, Outjector outje...
### Question: Messages implements Serializable { public void assertAbsenceOfErrors() { if (hasUnhandledErrors()) { log.debug("Some validation errors occured: {}", getErrors()); throw new ValidationFailedException( "There are validation errors and you forgot to specify where to go. Please add in your method " + "somethi...
### Question: Messages implements Serializable { public Messages add(Message message) { get(message.getSeverity()).add(message); if(Severity.ERROR.equals(message.getSeverity())) { unhandledErrors = true; } return this; } Messages add(Message message); List<Message> getErrors(); List<Message> getInfo(); List<Message> g...
### Question: DateConverter implements Converter<Date> { @Override public Date convert(String value, Class<? extends Date> type) { if (isNullOrEmpty(value)) { return null; } try { return getDateFormat().parse(value); } catch (ParseException pe) { throw new ConversionException(new ConversionMessage(INVALID_MESSAGE_KEY, ...
### Question: PrimitiveLongConverter implements Converter<Long> { @Override public Long convert(String value, Class<? extends Long> type) { if (isNullOrEmpty(value)) { return 0L; } try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(INVALID_MESSAGE...
### Question: CalendarConverter implements Converter<Calendar> { @Override public Calendar convert(String value, Class<? extends Calendar> type) { if (isNullOrEmpty(value)) { return null; } try { Date date = getDateFormat().parse(value); Calendar calendar = Calendar.getInstance(locale); calendar.setTime(date); return c...
### Question: PrimitiveByteConverter implements Converter<Byte> { @Override public Byte convert(String value, Class<? extends Byte> type) { if (isNullOrEmpty(value)) { return (byte) 0; } try { return Byte.parseByte(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(INVALID_M...
### Question: LongConverter implements Converter<Long> { @Override public Long convert(String value, Class<? extends Long> type) { if (isNullOrEmpty(value)) { return null; } try { return Long.valueOf(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(INVALID_MESSAGE_KEY, val...
### Question: PrimitiveFloatConverter implements Converter<Float> { @Override public Float convert(String value, Class<? extends Float> type) { if (isNullOrEmpty(value)) { return 0f; } try { return getNumberFormat().parse(value).floatValue(); } catch (ParseException e) { throw new ConversionException(new ConversionMess...
### Question: CharacterConverter implements Converter<Character> { @Override public Character convert(String value, Class<? extends Character> type) { if (isNullOrEmpty(value)) { return null; } if (value.length() != 1) { throw new ConversionException(new ConversionMessage(INVALID_MESSAGE_KEY, value)); } return value.ch...
### Question: PrimitiveShortConverter implements Converter<Short> { @Override public Short convert(String value, Class<? extends Short> type) { if (isNullOrEmpty(value)) { return (short) 0; } try { return Short.parseShort(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(IN...
### Question: PrimitiveIntConverter implements Converter<Integer> { @Override public Integer convert(String value, Class<? extends Integer> type) { if (isNullOrEmpty(value)) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(INVALI...
### Question: ByteConverter implements Converter<Byte> { @Override public Byte convert(String value, Class<? extends Byte> type) { if (isNullOrEmpty(value)) { return null; } try { return Byte.valueOf(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(INVALID_MESSAGE_KEY, val...
### Question: PrimitiveCharConverter implements Converter<Character> { @Override public Character convert(String value, Class<? extends Character> type) { if (isNullOrEmpty(value)) { return '\u0000'; } if (value.length() != 1) { throw new ConversionException(new ConversionMessage(INVALID_MESSAGE_KEY, value)); } return ...
### Question: BigDecimalConverter implements Converter<BigDecimal> { @Override public BigDecimal convert(String value, Class<? extends BigDecimal> type) { if (isNullOrEmpty(value)) { return null; } try { return (BigDecimal) getNumberFormat().parse(value); } catch (ParseException e) { throw new ConversionException(new C...
### Question: IntegerConverter implements Converter<Integer> { @Override public Integer convert(String value, Class<? extends Integer> type) { if (isNullOrEmpty(value)) { return null; } try { return Integer.valueOf(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(INVALID_M...
### Question: BigIntegerConverter implements Converter<BigInteger> { @Override public BigInteger convert(String value, Class<? extends BigInteger> type) { if (isNullOrEmpty(value)) { return null; } try { return new BigInteger(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessag...
### Question: FloatConverter implements Converter<Float> { @Override public Float convert(String value, Class<? extends Float> type) { if (isNullOrEmpty(value)) { return null; } try { return getNumberFormat().parse(value).floatValue(); } catch (ParseException e) { throw new ConversionException(new ConversionMessage(INV...
### Question: ShortConverter implements Converter<Short> { @Override public Short convert(String value, Class<? extends Short> type) { if (isNullOrEmpty(value)) { return null; } try { return Short.valueOf(value); } catch (NumberFormatException e) { throw new ConversionException(new ConversionMessage(INVALID_MESSAGE_KEY...
### Question: EnumConverter implements Converter { @Override public Object convert(String value, Class type) { if (isNullOrEmpty(value)) { return null; } if (Character.isDigit(value.charAt(0))) { return resolveByOrdinal(value, type); } else { return resolveByName(value, type); } } @Override Object convert(String value...
### Question: HomeController { @Post @Public public void login(String login, String password) { final User currentUser = dao.find(login, password); validator.check(currentUser != null, new SimpleMessage("login", "invalid_login_or_password")); validator.onErrorUsePageOf(this).login(); userInfo.login(currentUser); result...
### Question: HomeController { public void logout() { userInfo.logout(); result.redirectTo(this).login(); } protected HomeController(); @Inject HomeController(UserDao dao, UserInfo userInfo, Result result, Validator validator); @Post @Public void login(String login, String password); void logout(); @Public @Get void ...
### Question: UsersController { @Get("/") public void home() { result.include("musicTypes", MusicType.values()); } protected UsersController(); @Inject UsersController(UserDao dao, Result result, Validator validator, UserInfo userInfo, MusicDao musicDao); @Get("/") void home(); @Get("/users") void list(); @Path("...
### Question: UsersController { @Get("/users") public void list() { result.include("users", userDao.listAll()); } protected UsersController(); @Inject UsersController(UserDao dao, Result result, Validator validator, UserInfo userInfo, MusicDao musicDao); @Get("/") void home(); @Get("/users") void list(); @Path("/...
### Question: UsersController { @Path("/users") @Post @Public public void add(@Valid @LoginAvailable User user) { validator.onErrorUsePageOf(HomeController.class).login(); userDao.add(user); result.include("notice", "User " + user.getName() + " successfully added"); result.redirectTo(HomeController.class).login(); } pr...
### Question: UsersController { @Path("/users/{user.login}") @Get public void show(User user) { result.include("user", userDao.find(user.getLogin())); result.forwardTo("/WEB-INF/jsp/users/view.jsp"); } protected UsersController(); @Inject UsersController(UserDao dao, Result result, Validator validator, UserInfo u...
### Question: MusicController { @Path("/musics") @Post public void add(final @NotNull @Valid Music music, UploadedFile file) { validator.onErrorForwardTo(UsersController.class).home(); musicDao.add(music); User currentUser = userInfo.getUser(); userDao.refresh(currentUser); currentUser.add(music); if (file != null) { m...
### Question: MusicController { @Path("/musics/{music.id}") @Get public void show(Music music) { result.include("music", musicDao.load(music)); } protected MusicController(); @Inject MusicController(MusicDao musicDao, UserInfo userInfo, Result result, Validator validator, Musics musics, UserDao userDao); @Path("...
### Question: VRaptorRequest extends HttpServletRequestWrapper implements MutableRequest { @Override public String getRequestedUri() { if (getAttribute(INCLUDE_REQUEST_URI) != null) { return (String) getAttribute(INCLUDE_REQUEST_URI); } String uri = getRelativeRequestURI(this); return uri.replaceFirst("(?i);jsessionid=...
### Question: MusicController { @Get("/musics/search") public void search(Music music) { String title = MoreObjects.firstNonNull(music.getTitle(), ""); result.include("musics", this.musicDao.searchSimilarTitle(title)); } protected MusicController(); @Inject MusicController(MusicDao musicDao, UserInfo userInfo, R...
### Question: MusicController { @Path("/musics/download/{m.id}") @Get public Download download(Music m) throws FileNotFoundException { Music music = musicDao.load(m); File file = musics.getFile(music); String contentType = "audio/mpeg"; String filename = music.getTitle() + ".mp3"; return new FileDownload(file, contentT...
### Question: MusicController { @Public @Path("/musics/list/json") public void showAllMusicsAsJSON() { result.use(json()).from(musicDao.listAll()).serialize(); } protected MusicController(); @Inject MusicController(MusicDao musicDao, UserInfo userInfo, Result result, Validator validator, Musics musics, UserDao u...
### Question: MusicController { @Public @Path("/musics/list/xml") public void showAllMusicsAsXML() { result.use(xml()).from(musicDao.listAll()).serialize(); } protected MusicController(); @Inject MusicController(MusicDao musicDao, UserInfo userInfo, Result result, Validator validator, Musics musics, UserDao user...
### Question: MusicController { @Public @Path("/musics/list/http") public void showAllMusicsAsHTTP() { result.use(http()).body("<p class=\"content\">"+ musicDao.listAll().toString()+"</p>"); } protected MusicController(); @Inject MusicController(MusicDao musicDao, UserInfo userInfo, Result result, Validator vali...
### Question: MusicController { @Public @Path("musics/listAs") public void listAs() { result.use(representation()) .from(musicDao.listAll()).serialize(); } protected MusicController(); @Inject MusicController(MusicDao musicDao, UserInfo userInfo, Result result, Validator validator, Musics musics, UserDao userDao...
### Question: Rules { protected final RouteBuilder routeFor(String uri) { RouteBuilder rule = router.builderFor(uri); rule.withPriority(Integer.MIN_VALUE); this.routesToBuild.add(rule); return rule; } Rules(Router router); abstract void routes(); }### Answer: @Test public void allowsAdditionOfRouteBuildersByDefaultWit...
### Question: DefaultRouter implements Router { @Override public <T> String urlFor(final Class<T> type, final Method method, Object... params) { final Class<?> rawtype = proxifier.isProxyType(type) ? type.getSuperclass() : type; final Invocation invocation = new Invocation(rawtype, method); Route route = cache.fetch(in...
### Question: AVSessionCacheHelper { static synchronized SessionTagCache getTagCacheInstance() { if (null == tagCacheInstance) { tagCacheInstance = new SessionTagCache(); } return tagCacheInstance; } }### Answer: @Test public void testRemoveNotExistTag() { AVSessionCacheHelper.getTagCacheInstance().addSession(testCl...
### Question: AVSMS { public static void requestSMSCode(String phone, AVSMSOption smsOption) throws AVException { requestSMSCodeInBackground(phone, smsOption, true, new RequestMobileCodeCallback() { @Override public void done(AVException e) { if (e != null) { AVExceptionHolder.add(e); } } @Override public boolean mustR...
### Question: AVSMS { public static void verifySMSCode(String code, String mobilePhoneNumber) throws AVException { verifySMSCodeInBackground(code, mobilePhoneNumber, true, new AVMobilePhoneVerifyCallback() { @Override public void done(AVException e) { if (e != null) { AVExceptionHolder.add(e); } } @Override public bool...
### Question: AVSMS { public static void verifySMSCodeInBackground(String code, String phoneNumber, AVMobilePhoneVerifyCallback callback) { verifySMSCodeInBackground(code, phoneNumber, false, callback); } static void requestSMSCode(String phone, AVSMSOption smsOption); static void requestSMSCodeInBackground(String pho...
### Question: SnackbarAdapter extends RecyclerView.Adapter<SnackbarAdapter.ViewHolder> { public boolean isEmpty() { return mSnackbarViews == null || mSnackbarViews.size() == 0; } @Override ViewHolder onCreateViewHolder(ViewGroup parent, int position); @Override void onBindViewHolder(ViewHolder holder, int position); @...
### Question: SnackbarAdapter extends RecyclerView.Adapter<SnackbarAdapter.ViewHolder> { @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int position) { View view = mSnackbarViews.get(position).onCreateView(parent); ViewHolder viewHolder = new ViewHolder(view); return viewHolder; } @Override ViewHolde...
### Question: SnackbarAdapter extends RecyclerView.Adapter<SnackbarAdapter.ViewHolder> { @Override public void onBindViewHolder(ViewHolder holder, int position) { SnackbarView snackbarView = mSnackbarViews.get(position); if (snackbarView != null) { snackbarView.onBindView(); } } @Override ViewHolder onCreateViewHolder...
### Question: SnackbarAdapter extends RecyclerView.Adapter<SnackbarAdapter.ViewHolder> { public synchronized void addItem(SnackbarView item) { mSnackbarViews.add(item); int position = mSnackbarViews.indexOf(item); notifyItemInserted(position); } @Override ViewHolder onCreateViewHolder(ViewGroup parent, int position); ...
### Question: SnackbarAdapter extends RecyclerView.Adapter<SnackbarAdapter.ViewHolder> { public synchronized void removeItem(SnackbarView view) { int position = mSnackbarViews.indexOf(view); if (position > -1) { mSnackbarViews.remove(position); notifyItemRemoved(position); } } @Override ViewHolder onCreateViewHolder(V...
### Question: NumberInterval { @Override public boolean equals(Object obj) { if (!(obj instanceof NumberInterval)) { return false; } NumberInterval rhs = (NumberInterval) obj; return Objects.equals(low, rhs.low) && Objects.equals(high, rhs.high); } NumberInterval(); NumberInterval(NumberIntervalBoundary low, NumberInt...
### Question: StringAttributeDomainDto extends AttributeDomainDto { @Override public void validate() throws BadValueException { if (regex == null) { return; } try { Pattern.compile(regex); } catch (PatternSyntaxException ex) { throw new BadValueException("Invalid regex: " + ex.getMessage(), ex); } } StringAttributeDoma...
### Question: NumberIntervalBoundary { @Override public int hashCode() { return Objects.hash(this.boundary, isInclusive() ? Boolean.TRUE : Boolean.FALSE); } NumberIntervalBoundary(); NumberIntervalBoundary(Double boundary); NumberIntervalBoundary(Double boundary, Boolean inclusive); @Override boolean equals(Object ob...
### Question: NumberIntervalBoundary { @JsonIgnore public boolean isInclusive() { return inclusive != null && inclusive; } NumberIntervalBoundary(); NumberIntervalBoundary(Double boundary); NumberIntervalBoundary(Double boundary, Boolean inclusive); @Override boolean equals(Object obj); @Override int hashCode(); int ...
### Question: NumberIntervalBoundary { public int compareBoundaryTo(NumberIntervalBoundary rhs) { return boundary.compareTo(rhs.getBoundary()); } NumberIntervalBoundary(); NumberIntervalBoundary(Double boundary); NumberIntervalBoundary(Double boundary, Boolean inclusive); @Override boolean equals(Object obj); @Overri...
### Question: NumberInterval { @Override public String toString() { return lowToString() + ", " + highToString(); } NumberInterval(); NumberInterval(NumberIntervalBoundary low, NumberIntervalBoundary high); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); void validate(); bo...
### Question: NumberIntervalBoundary { public void validate() throws BadValueException { if (boundary == null) { throw new BadValueException("NumberIntervalBoundary.boundary is required"); } } NumberIntervalBoundary(); NumberIntervalBoundary(Double boundary); NumberIntervalBoundary(Double boundary, Boolean inclusive)...
### Question: AgentServiceClient extends ServiceClientBase<AgentDto, ApiObjectRef> implements AgentService { @Override public ApiObjectRef create(CreateAgentArg createArg, String routerRef) throws CommsRouterException { return post(createArg, routerRef); } @Inject AgentServiceClient(Client client, String endpoint, Str...
### Question: AgentServiceClient extends ServiceClientBase<AgentDto, ApiObjectRef> implements AgentService { @Override public ApiObjectRef replace(CreateAgentArg createArg, RouterObjectRef objectRef) throws CommsRouterException { return put(createArg, objectRef); } @Inject AgentServiceClient(Client client, String endp...
### Question: AgentServiceClient extends ServiceClientBase<AgentDto, ApiObjectRef> implements AgentService { @Override public void update(UpdateAgentArg updateArg, RouterObjectRef objectRef) throws CommsRouterException { post(updateArg, objectRef); } @Inject AgentServiceClient(Client client, String endpoint, String ro...
### Question: AgentServiceClient extends ServiceClientBase<AgentDto, ApiObjectRef> implements AgentService { @Override public AgentDto get(RouterObjectRef routerObjectRef) throws CommsRouterException { return getItem(routerObjectRef); } @Inject AgentServiceClient(Client client, String endpoint, String routerRef); @Ove...
### Question: AgentServiceClient extends ServiceClientBase<AgentDto, ApiObjectRef> implements AgentService { @Override public PaginatedList<AgentDto> list(PagingRequest request) throws CommsRouterException { PagingRequest pagingRequest = new PagingRequest( routerRef, request.getToken(), request.getPerPage(), request.ge...
### Question: AgentServiceClient extends ServiceClientBase<AgentDto, ApiObjectRef> implements AgentService { @Override public void delete(RouterObjectRef routerObjectRef) { routerObjectRef.setRouterRef(routerRef); deleteRequest(routerObjectRef); } @Inject AgentServiceClient(Client client, String endpoint, String route...
### Question: ConfigurationImpl implements Configuration { @Override public JWTAuthMethod getJwtAuthMethod() { return jwtAuthMethod; } @Inject ConfigurationImpl(ConfigurationProperties properties); @Override JWTAuthMethod getJwtAuthMethod(); @Override Endpoint getAssociatedPhone(); @Override String getCallbackBaseUrl(...
### Question: ConfigurationImpl implements Configuration { @Override public Endpoint getAssociatedPhone() { return phoneEndpoint; } @Inject ConfigurationImpl(ConfigurationProperties properties); @Override JWTAuthMethod getJwtAuthMethod(); @Override Endpoint getAssociatedPhone(); @Override String getCallbackBaseUrl(); ...
### Question: ConfigurationImpl implements Configuration { @Override public String getCallbackBaseUrl() { return callbackBaseUrl; } @Inject ConfigurationImpl(ConfigurationProperties properties); @Override JWTAuthMethod getJwtAuthMethod(); @Override Endpoint getAssociatedPhone(); @Override String getCallbackBaseUrl(); ...
### Question: Cfg4jConfiguration implements ConfigurationProperties { @Override public String callbackBaseUrl() { return provider.getProperty("app.callbackBaseUrl", String.class); } Cfg4jConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override Str...
### Question: Cfg4jConfiguration implements ConfigurationProperties { @Override public String phone() { return provider.getProperty("app.phone", String.class); } Cfg4jConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override String commsRouterUrl()...
### Question: Cfg4jConfiguration implements ConfigurationProperties { @Override public String appId() { return provider.getProperty("nexmo.appId", String.class); } Cfg4jConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override String commsRouterUrl...
### Question: Cfg4jConfiguration implements ConfigurationProperties { @Override public String appPrivateKey() { return provider.getProperty("nexmo.appPrivateKey", String.class); } Cfg4jConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override Strin...
### Question: PropertiesConfiguration implements ConfigurationProperties { @Override public String callbackBaseUrl() { return properties.getProperty(CALLBACK_BASE_URL); } PropertiesConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override String co...
### Question: PropertiesConfiguration implements ConfigurationProperties { @Override public String phone() { return properties.getProperty(APP_PHONE); } PropertiesConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override String commsRouterUrl(); @O...
### Question: PropertiesConfiguration implements ConfigurationProperties { @Override public String appId() { return properties.getProperty(NEXMO_APP_ID); } PropertiesConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override String commsRouterUrl();...
### Question: PropertiesConfiguration implements ConfigurationProperties { @Override public String appPrivateKey() { return properties.getProperty(NEXMO_APP_PRIVATE_KEY); } PropertiesConfiguration(); @Override String callbackBaseUrl(); @Override String nexmoCallbackBaseUrl(); @Override String phone(); @Override String ...
### Question: JEvalEvaluator implements CommsRouterEvaluator { @Override public void validate() throws ExpressionException { long millis = System.currentTimeMillis(); evaluator.validateImpl(); LOGGER.trace("Predicate expression validation time is: {}", (System.currentTimeMillis() - millis)); } JEvalEvaluator(CommsRoute...
### Question: RsqlEvaluatorFactory { public boolean evaluate(String expression, AttributeGroup attributeGroup, String routerRef) throws ExpressionException { return create(expression, routerRef).evaluate(attributeGroup); } RsqlEvaluatorFactory(CommsRouterEvaluatorFactory factory); Node parse(String expression); void va...
### Question: RsqlEvaluatorFactory { public void validate(String expression) throws ExpressionException { try { parse(expression); } catch (RSQLParserException ex) { throw new ExpressionException("Invalid expression: " + ex.getMessage()); } } RsqlEvaluatorFactory(CommsRouterEvaluatorFactory factory); Node parse(String ...
### Question: AttributeDomainMapper { public static AttributeType getAttributeType(AttributeDomainDefinition jpa) { if (jpa.getEnumValue() != null) { assert jpa.getBoundary() == null && jpa.getInclusive() == null && jpa.getRegex() == null; return AttributeType.enumeration; } if (jpa.getBoundary() != null) { assert jpa....
### Question: RouterObject extends ApiObject { @Override public boolean equals(Object object) { boolean equals = super.equals(object); if (equals) { RouterObject routerObject = (RouterObject) object; return Objects.equals(getRouter(), routerObject.getRouter()); } return false; } RouterObject(); RouterObject(RouterObje...
### Question: RouterObject extends ApiObject { @Override public int hashCode() { return Objects.hash(getRef(), getRouter(), getVersion(), getClass()); } RouterObject(); RouterObject(RouterObject rhs); RouterObject(String id); Router getRouter(); void setRouter(Router router); @Override String toString(); @Override bo...
### Question: AdjustableSemaphore extends Semaphore { public synchronized void setMaxPermits(int maxPermits) { if (maxPermits < 1) { throw new IllegalArgumentException("Semaphore size(" + maxPermits + ") must be at least 1"); } int delta = maxPermits - this.maxPermits; if (delta == 0) { return; } else if (delta > 0) { ...
### Question: RetryerBuilder { public RetryerBuilder<V> withWaitStrategy(WaitStrategy waitStrategy) throws IllegalStateException { Preconditions.checkNotNull(waitStrategy, "waitStrategy may not be null"); Preconditions.checkState(this.waitStrategy == null, "a wait strategy has already been set %s", this.waitStrategy); ...
### Question: RetryerBuilder { public RetryerBuilder<V> withStopStrategy(StopStrategy stopStrategy) throws IllegalStateException { Preconditions.checkNotNull(stopStrategy, "stopStrategy may not be null"); Preconditions.checkState(this.stopStrategy == null, "a stop strategy has already been set %s", this.stopStrategy); ...
### Question: RetryerBuilder { public RetryerBuilder<V> withBlockStrategy(BlockStrategy blockStrategy) throws IllegalStateException { Preconditions.checkNotNull(blockStrategy, "blockStrategy may not be null"); Preconditions.checkState(this.blockStrategy == null, "a block strategy has already been set %s", this.blockStr...
### Question: RetryerBuilder { public RetryerBuilder<V> retryIfResult(Predicate<V> resultPredicate) { Preconditions.checkNotNull(resultPredicate, "resultPredicate may not be null"); rejectionPredicate = Predicates.or(rejectionPredicate, new ResultPredicate<V>(resultPredicate)); return this; } private RetryerBuilder();...
### Question: AttemptTimeLimiters { public static <V> AttemptTimeLimiter<V> fixedTimeLimit(long duration, TimeUnit timeUnit) { Preconditions.checkNotNull(timeUnit); return new FixedAttemptTimeLimit<V>(duration, timeUnit); } private AttemptTimeLimiters(); static AttemptTimeLimiter<V> noTimeLimit(); static AttemptTimeLi...
### Question: CircuitBreaker { public void open() { lastOpenedTime = System.currentTimeMillis(); state = CircuitBreakerState.OPEN; logger.debug("circuit open,key:{}", name); } CircuitBreaker(String name, CircuitBreakerConfig config); boolean isOpen(); boolean isHalfOpen(); boolean isClosed(); void open(); void openHalf...
### Question: JavaVersion { static Version parseVersion(String version) { if (version.startsWith("1.")) { String[] versions = version.split("\\."); if (versions.length <= 1) { throw new IllegalStateException("Invalid Java version: " + version); } return new Version(1, Integer.parseInt(versions[1])); } else { final Matc...
### Question: FileStringBinding extends AbstractStringBinding<File> implements Binding<File, String> { @Override public File unmarshal(String object) { return new File(object); } @Override File unmarshal(String object); Class<File> getBoundClass(); }### Answer: @Test public void testUnmarshal() { assertEquals(new Fil...
### Question: StringBuilderStringBinding extends AbstractStringBinding<StringBuilder> implements Binding<StringBuilder, String> { @Override public StringBuilder unmarshal(String object) { return new StringBuilder(object); } @Override StringBuilder unmarshal(String object); Class<StringBuilder> getBoundClass(); }### A...
### Question: StringBufferStringBinding extends AbstractStringBinding<StringBuffer> implements Binding<StringBuffer, String> { @Override public StringBuffer unmarshal(String object) { return new StringBuffer(object); } @Override StringBuffer unmarshal(String object); Class<StringBuffer> getBoundClass(); }### Answer: ...
### Question: URIStringBinding extends AbstractStringBinding<URI> implements Binding<URI, String> { @Override public URI unmarshal(String object) { return URI.create(object); } @Override URI unmarshal(String object); Class<URI> getBoundClass(); }### Answer: @Test public void testUnmarshal(){ assertEquals(URI.create("...
### Question: URLStringBinding extends AbstractStringBinding<URL> implements Binding<URL, String> { @Override public URL unmarshal(String object) { try { return new URL(object); } catch (MalformedURLException ex) { throw new IllegalArgumentException(object + " is not a valid URL"); } } @Override URL unmarshal(String o...
### Question: BooleanStringBinding extends AbstractStringBinding<Boolean> implements Binding<Boolean, String> { @Override public Boolean unmarshal(String object) { return Boolean.valueOf(object); } @Override Boolean unmarshal(String object); Class<Boolean> getBoundClass(); }### Answer: @Test public void testUnmarshal...
### Question: LocaleStringBinding extends AbstractStringBinding<Locale> implements Binding<Locale, String> { @Override public Locale unmarshal(String object) { String[] components = object.split("_", 3); final Locale result; if (components.length == 1) { result = new Locale(components[0]); } else if (components.length ...
### Question: StringStringBinding extends AbstractStringBinding<String> implements Binding<String, String> { @Override public String unmarshal(String object) { return object; } @Override String unmarshal(String object); Class<String> getBoundClass(); }### Answer: @Test public void testUnmarshal() { assertEquals("Hell...
### Question: IntervalBisection implements CompositeFunction<Double, QuantitativeFunction<Double, Double>> { public IntervalBisection(double lowerBound, double higherBound) { this(lowerBound, higherBound, 20); } IntervalBisection(double lowerBound, double higherBound); IntervalBisection(double lowerBound, double highe...
### Question: PackageStringBinding extends AbstractStringBinding<Package> implements Binding<Package, String> { @Override public Package unmarshal(String object) { return Package.getPackage(object); } @Override String marshal(Package object); @Override Package unmarshal(String object); Class<Package> getBoundClass(); ...
### Question: PackageStringBinding extends AbstractStringBinding<Package> implements Binding<Package, String> { @Override public String marshal(Package object) { return ((Package) object).getName(); } @Override String marshal(Package object); @Override Package unmarshal(String object); Class<Package> getBoundClass(); ...
### Question: IntegerStringBinding extends AbstractStringBinding<Integer> implements Binding<Integer, String> { @Override public Integer unmarshal(String object) { return Integer.valueOf(Integer.parseInt(object)); } @Override Integer unmarshal(String object); Class<Integer> getBoundClass(); }### Answer: @Test public ...
### Question: BigIntegerStringBinding extends AbstractStringBinding<BigInteger> implements Binding<BigInteger, String> { @Override public BigInteger unmarshal(String object) { return new BigInteger(object); } @Override BigInteger unmarshal(String object); Class<BigInteger> getBoundClass(); }### Answer: @Test public v...
### Question: UUIDStringBinding extends AbstractStringBinding<UUID> implements Binding<UUID, String> { @Override public UUID unmarshal(String object) { return java.util.UUID.fromString(object); } @Override UUID unmarshal(String object); Class<UUID> getBoundClass(); }### Answer: @Test public void testUnmarshal(){ asse...