method2testcases stringlengths 118 6.63k |
|---|
### Question:
Pagination extends AbstractSchemaGenerator { public Schema schema() { return new ObjectSchema() .addProperties( "first", new StringSchema() .description("The first page of data") .format("uri") .nullable(true)) .addProperties( "last", new StringSchema() .description("The last page of data") .format("uri")... |
### Question:
ResourceReferencesResponse extends AbstractResponseGenerator { public ApiResponse response() { return new ApiResponse() .description(HttpStatus.toMessage(200)) .content( new Content() .addMediaType( "application/vnd.api+json", new MediaType() .schema(new ResourceReferencesResponseSchema(metaResource).$ref... |
### Question:
NoContent extends AbstractResponseGenerator { public ApiResponse response() { return new ApiResponse() .description("No Content"); } ApiResponse response(); }### Answer:
@Test void response() { ApiResponse apiResponse = new NoContent().response(); Assert.assertEquals("No Content", apiResponse.getDescrip... |
### Question:
ResourceResponse extends AbstractResponseGenerator { public ApiResponse response() { return new ApiResponse() .description(HttpStatus.toMessage(200)) .content( new Content() .addMediaType( "application/vnd.api+json", new MediaType() .schema(new ResourceResponseSchema(metaResource).$ref()))); } ResourceRes... |
### Question:
StaticResponses { public static Map<String, ApiResponse> generateStandardApiResponses() { return OASMergeUtil.mergeApiResponses(generateStandardApiSuccessResponses(), OASErrors.generateStandardApiErrorResponses()); } static Map<String, ApiResponse> generateStandardApiResponses(); }### Answer:
@Test void... |
### Question:
ResourcesResponse extends AbstractResponseGenerator { public ApiResponse response() { return new ApiResponse() .description(HttpStatus.toMessage(200)) .content( new Content() .addMediaType( "application/vnd.api+json", new MediaType() .schema(new ResourcesResponseSchema(metaResource).$ref()))); } Resources... |
### Question:
ResourceReferenceResponse extends AbstractResponseGenerator { public ApiResponse response() { return new ApiResponse() .description(HttpStatus.toMessage(200)) .content( new Content() .addMediaType( "application/vnd.api+json", new MediaType() .schema(new ResourceReferenceResponseSchema(metaResource).$ref()... |
### Question:
OASMergeUtil { public static Operation mergeOperations(Operation thisOperation, Operation thatOperation) { if (thatOperation == null) { return thisOperation; } if (thatOperation.getTags() != null) { thisOperation.setTags( mergeTags(thisOperation.getTags(), thatOperation.getTags()) ); } if (thatOperation.g... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { public MetaAttributePath concat(MetaAttribute... pathElements) { ArrayList<MetaAttribute> list = new ArrayList<>(); list.addAll(Arrays.asList(this.pathElements)); list.addAll(Arrays.asList(pathElements)); return to(list.toArray(newArray(0))); } MetaAt... |
### Question:
NestedFilter extends AbstractParameterGenerator { public Parameter parameter() { return new Parameter() .name("filter") .description("Customizable query (experimental)") .in("query") .schema( new ObjectSchema() .addProperties( "AND", new ObjectSchema() .additionalProperties(true) .nullable(true)) .addProp... |
### Question:
PrimaryKey extends AbstractParameterGenerator { public Parameter parameter() { MetaResourceField metaResourceField = OASUtils.getPrimaryKeyMetaResourceField(metaResource); return new Parameter() .name(metaResourceField.getName()) .in("path") .schema(new ResourceAttribute(metaResource, metaResourceField).$... |
### Question:
FieldFilter extends AbstractParameterGenerator { public Parameter parameter() { return new Parameter() .name("filter[" + metaResourceField.getName() + "]") .description("Filter by " + metaResourceField.getName() + " (csv)") .in("query") .schema(new StringSchema()); } FieldFilter(MetaResource metaResource,... |
### Question:
Fields extends AbstractParameterGenerator { public Parameter parameter() { return new Parameter() .name("fields") .description(metaResource.getResourceType() + " fields to include (csv)") .in("query") .schema(new StringSchema() ._default( OASUtils.attributes(metaResource, true) .map(MetaElement::getName) ... |
### Question:
Include extends AbstractParameterGenerator { public Parameter parameter() { return new Parameter() .name("include") .description(metaResource.getResourceType() + " relationships to include (csv)") .in("query") .schema(new StringSchema() ._default( metaResource .getAttributes() .stream() .filter(MetaAttrib... |
### Question:
Sort extends AbstractParameterGenerator { public Parameter parameter() { return new Parameter() .name("sort") .description(metaResource.getResourceType() + " sort order (csv)") .in("query") .schema(new StringSchema() .example( OASUtils.sortAttributes(metaResource, true) .map(MetaElement::getName) .collect... |
### Question:
OASErrors { public static Map<String, ApiResponse> generateStandardApiErrorResponses() { Map<String, ApiResponse> responses = new LinkedHashMap<>(); List<Integer> responseCodes = getStandardHttpStatusCodes(); for (Integer responseCode : responseCodes) { if (responseCode >= 400 && responseCode <= 599) { Ap... |
### Question:
TSFunction extends TSMember implements TSExportedElement { @Override public boolean isField() { return false; } @Override void accept(TSVisitor visitor); List<String> getStatements(); List<TSParameter> getParameters(); void setExported(boolean exported); @Override boolean isExported(); void addParameter(... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { @Override public String toString() { return render(PATH_SEPARATOR); } MetaAttributePath(List<? extends MetaAttribute> pathElements); MetaAttributePath(MetaAttribute... pathElements); MetaAttributePath subPath(int startIndex); MetaAttributePath subPat... |
### Question:
TSFunction extends TSMember implements TSExportedElement { @Override public TSField asField() { throw new UnsupportedOperationException(); } @Override void accept(TSVisitor visitor); List<String> getStatements(); List<TSParameter> getParameters(); void setExported(boolean exported); @Override boolean isE... |
### Question:
TSGenerator { protected TSElement transform(MetaElement element, TSMetaTransformationOptions options) { if (elementSourceMap.containsKey(element)) { return elementSourceMap.get(element); } if (postProcessing) { throw new IllegalStateException("cannot add further element while post processing: " + element.... |
### Question:
TSImportProcessor implements TSSourceProcessor { @Override public List<TSSource> process(List<TSSource> sources) { for (TSSource source : sources) { transform(source); sortImports(source); } return sources; } @Override List<TSSource> process(List<TSSource> sources); }### Answer:
@Test public void sameDi... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + Arrays.hashCode(pathElements); return result; } MetaAttributePath(List<? extends MetaAttribute> pathElements); MetaAttributePath(MetaAttribute... pathEl... |
### Question:
UIModule implements Module { @Override public void setupModule(ModuleContext context) { this.context = context; if(config.isBrowserEnabled()) { context.addHttpRequestProcessor(new UIHttpRequestProcessor(config)); setupHomeExtension(context); } if (config != null && config.isPresentationModelEnabled()) { S... |
### Question:
UIModule implements Module { public static UIModule create(UIModuleConfig config) { return new UIModule(config); } protected UIModule(); protected UIModule(UIModuleConfig config); static UIModule create(UIModuleConfig config); String getModuleName(); @Override void setupModule(ModuleContext context); Pr... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { public int length() { return pathElements.length; } MetaAttributePath(List<? extends MetaAttribute> pathElements); MetaAttributePath(MetaAttribute... pathElements); MetaAttributePath subPath(int startIndex); MetaAttributePath subPath(int startIndex, ... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { public MetaAttribute getLast() { if (pathElements != null && pathElements.length > 0) { return pathElements[pathElements.length - 1]; } return null; } MetaAttributePath(List<? extends MetaAttribute> pathElements); MetaAttributePath(MetaAttribute... p... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { @Override public Iterator<MetaAttribute> iterator() { return Collections.unmodifiableList(Arrays.asList(pathElements)).iterator(); } MetaAttributePath(List<? extends MetaAttribute> pathElements); MetaAttributePath(MetaAttribute... pathElements); Meta... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { public MetaAttribute getElement(int index) { return pathElements[index]; } MetaAttributePath(List<? extends MetaAttribute> pathElements); MetaAttributePath(MetaAttribute... pathElements); MetaAttributePath subPath(int startIndex); MetaAttributePath s... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { public MetaAttributePath subPath(int startIndex) { MetaAttribute[] range = Arrays.copyOfRange(pathElements, startIndex, pathElements.length); return new MetaAttributePath(range); } MetaAttributePath(List<? extends MetaAttribute> pathElements); MetaAt... |
### Question:
ResourcePermission { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (deleteAllowed ? 1231 : 1237); result = prime * result + (getAllowed ? 1231 : 1237); result = prime * result + (patchAllowed ? 1231 : 1237); result = prime * result + (postAllowed ? 1231 ... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { public String render(String delimiter) { if (pathElements.length == 0) { return ""; } else if (pathElements.length == 1) { return pathElements[0].getName(); } else { StringBuilder builder = new StringBuilder(pathElements[0].getName()); for (int i = 1;... |
### Question:
MetaAttributePath implements Iterable<MetaAttribute> { @Override public boolean equals(Object obj) { if (obj instanceof MetaAttributePath) { MetaAttributePath other = (MetaAttributePath) obj; return Arrays.equals(pathElements, other.pathElements); } return false; } MetaAttributePath(List<? extends MetaAtt... |
### Question:
MetaDataObject extends MetaType { public MetaAttributePath resolvePath(List<String> attrPath, boolean includeSubTypes) { MetaAttributeFinder finder = includeSubTypes ? SUBTYPE_ATTRIBUTE_FINDER : DEFAULT_ATTRIBUTE_FINDER; return resolvePath(attrPath, finder); } @JsonIgnore // TODO MetaAttribute getVersion... |
### Question:
MetaDataObject extends MetaType { public MetaAttribute findAttribute(String name, boolean includeSubTypes) { if (hasAttribute(name)) { return getAttribute(name); } if (includeSubTypes) { List<? extends MetaDataObject> transitiveSubTypes = getSubTypes(true, true); for (MetaDataObject subType : transitiveSu... |
### Question:
MetaDataObject extends MetaType { public MetaAttribute getAttribute(String name) { setupCache(); MetaAttribute attr = attrMap.get(name); PreconditionUtil.assertNotNull(getName() + "." + name, attr); return attr; } @JsonIgnore // TODO MetaAttribute getVersionAttribute(); List<? extends MetaAttribute> getA... |
### Question:
ResourcePermission { public ResourcePermission xor(ResourcePermission other) { boolean mergePush = postAllowed ^ other.postAllowed; boolean mergeGet = getAllowed ^ other.getAllowed; boolean mergePatch = patchAllowed ^ other.patchAllowed; boolean mergeDelete = deleteAllowed ^ other.deleteAllowed; return ne... |
### Question:
MetaMapAttribute extends MetaAttribute { public Object getKey() { MetaType keyType = mapType.getKeyType(); TypeParser typeParser = new TypeParser(); return typeParser.parse(keyString, (Class) keyType.getImplementationClass()); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public boolean isLazy() { return mapAttr.isLazy(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Override void setValue(Object dataObject, Obj... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public boolean isDerived() { return mapAttr.isDerived(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Override void setValue(Object dataObjec... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public Collection<Annotation> getAnnotations() { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Over... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public <T extends Annotation> T getAnnotation(Class<T> clazz) { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dat... |
### Question:
MetaMapAttribute extends MetaAttribute { public void setOppositeAttribute(MetaAttribute oppositeAttr) { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public boolean isAssociation() { return mapAttr.isAssociation(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Override void setValue(Object d... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public boolean isVersion() { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Override void setValue(O... |
### Question:
MetaMapAttribute extends MetaAttribute { public boolean isId() { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Override void setValue(Object dataObjec... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public MetaAttribute getOppositeAttribute() { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Overrid... |
### Question:
ResourcePermission { public ResourcePermission and(ResourcePermission other) { boolean mergePush = postAllowed && other.postAllowed; boolean mergeGet = getAllowed && other.getAllowed; boolean mergePatch = patchAllowed && other.patchAllowed; boolean mergeDelete = deleteAllowed && other.deleteAllowed; retur... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public Object getValue(Object dataObject) { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject); @Override ... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public void addValue(Object dataObject, Object value) { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject)... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public void removeValue(Object dataObject, Object value) { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObje... |
### Question:
MetaMapAttribute extends MetaAttribute { @Override public void setValue(Object dataObject, Object value) { throw new UnsupportedOperationException(); } MetaMapAttribute(MetaMapType mapType, MetaAttribute mapAttr, String keyString); @Override MetaType getType(); @Override Object getValue(Object dataObject)... |
### Question:
MetaKey extends MetaElement { public String toKeyString(Object id) { if (id == null) { return null; } PreconditionUtil.assertEquals("compound primary key not supported", 1, elements.size()); MetaAttribute keyAttr = elements.get(0); MetaType keyType = keyAttr.getType(); if (keyType instanceof MetaDataObjec... |
### Question:
MetaElement implements Cloneable { public MetaDataObject asDataObject() { if (!(this instanceof MetaDataObject)) { throw new IllegalStateException(getName() + " not a MetaDataObject"); } return (MetaDataObject) this; } MetaElement getParent(); void setParent(MetaElement parent); List<MetaElement> getChil... |
### Question:
MetaElement implements Cloneable { public MetaType asType() { if (!(this instanceof MetaType)) { throw new IllegalStateException(getName() + " not a MetaEntity"); } return (MetaType) this; } MetaElement getParent(); void setParent(MetaElement parent); List<MetaElement> getChildren(); void setChildren(Lis... |
### Question:
JpaEntityRepositoryBase extends JpaRepositoryBase<T> implements ResourceRepository<T, I>,
ResourceRegistryAware { @Override public Class<T> getResourceClass() { return repositoryConfig.getResourceClass(); } JpaEntityRepositoryBase(Class<T> entityClass); JpaEntityRepositoryBase(JpaRepositoryConfig<T> co... |
### Question:
JpaEntityRepositoryBase extends JpaRepositoryBase<T> implements ResourceRepository<T, I>,
ResourceRegistryAware { public Class<?> getEntityClass() { return repositoryConfig.getEntityClass(); } JpaEntityRepositoryBase(Class<T> entityClass); JpaEntityRepositoryBase(JpaRepositoryConfig<T> config); JpaQuer... |
### Question:
ResourcePermission { public ResourcePermission or(ResourcePermission other) { boolean mergePush = postAllowed || other.postAllowed; boolean mergeGet = getAllowed || other.getAllowed; boolean mergePatch = patchAllowed || other.patchAllowed; boolean mergeDelete = deleteAllowed || other.deleteAllowed; return... |
### Question:
MyService { public int calculateUserAge(User user) { return Period.between(user.getDateOfBirth(), LocalDate.now()).getYears(); } int calculateUserAge(User user); }### Answer:
@Test public void testService() { MyService myService = new MyService(); User user = new User("John", "john@yahoo.com"); user.set... |
### Question:
EmployeeService { public double calculateBonus(Employee user) { return 0.1 * user.getSalary(); } double calculateBonus(Employee user); }### Answer:
@Test public void testParameter() { Employee employee = new Employee("john@gmail.com", "John", 2000); if (logger.isDebugEnabled()) { logger.debug("The bonus... |
### Question:
Castle { public static String clientId() { return instance.identifier; } private Castle(Application application, CastleConfiguration castleConfiguration); static void configure(Application application, CastleConfiguration configuration); static void configure(Application application, String publishableKe... |
### Question:
Castle { public static boolean flushIfNeeded(String url) { if (isUrlWhiteListed(url)) { flush(); return true; } return false; } private Castle(Application application, CastleConfiguration castleConfiguration); static void configure(Application application, CastleConfiguration configuration); static void ... |
### Question:
Castle { public static void reset() { Castle.flush(); Castle.userId(null); Castle.userSignature(null); } private Castle(Application application, CastleConfiguration castleConfiguration); static void configure(Application application, CastleConfiguration configuration); static void configure(Application a... |
### Question:
Castle { static boolean isUrlWhiteListed(String urlString) { try { URL url = new URL(urlString); String baseUrl = url.getProtocol() + ": if (Castle.configuration().baseURLWhiteList() != null && !Castle.configuration().baseURLWhiteList().isEmpty()) { if (Castle.configuration().baseURLWhiteList().contains(b... |
### Question:
Castle { public static String userAgent() { return Utils.sanitizeHeader(String.format(Locale.US, "%s/%s (%d) (%s %s; Android %s; Castle %s)", instance.appName, instance.appVersion, instance.appBuild, Build.MANUFACTURER, Build.MODEL, Build.VERSION.RELEASE, BuildConfig.VERSION_NAME)); } private Castle(Appl... |
### Question:
Solve { Solve() { } Solve(); int solve(int dimension, int[][] gridCopy); static int[] rc2box(int i, int j); }### Answer:
@Test public void testInvalidGrid() { Solve grid1 = new Solve(); int[][] grid = { { 4, 8, 3, 7, 6, 9, 2, 1, 5 }, { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, { 1, 2, 3... |
### Question:
MatrixController { @RequestMapping(path = "/find/{petId}", method = RequestMethod.GET) @ResponseBody public String find(@PathVariable String petId, @MatrixVariable int q) { logger.info("petId:{},q:{}",petId,q); return petId + q; } @RequestMapping(path = "/find/{petId}", method = RequestMethod.GET) @Respo... |
### Question:
MatrixController { @RequestMapping(path = "/owners/{ownerId}/pets/{petId}", method = RequestMethod.GET) @ResponseBody public String find1( @MatrixVariable(name="q", pathVar="ownerId") int q1, @MatrixVariable(name="q", pathVar="petId") int q2) { return String.valueOf(q1+q2); } @RequestMapping(path = "/fin... |
### Question:
JsonController { @RequestMapping(path = "/get",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public User get(){ return new User(20,"李四","F"); } @RequestMapping(path = "/get",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @Respon... |
### Question:
JsonController { @RequestMapping(path = "/post/{name}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public User post(@PathVariable String name, Model model){ logger.info("name : {}",name); return new User(20,name,"男"); } @RequestMapping(path = "/get",metho... |
### Question:
XmlController { @RequestMapping(path = "/get",method = RequestMethod.GET,produces = MediaType.APPLICATION_XML_VALUE) @ResponseBody public User get(){ return new User(21,"张三","男"); } @RequestMapping(path = "/get",method = RequestMethod.GET,produces = MediaType.APPLICATION_XML_VALUE) @ResponseBody User get... |
### Question:
XmlController { @RequestMapping(path = "/post",method = RequestMethod.POST,produces = MediaType.APPLICATION_XML_VALUE,consumes = MediaType.APPLICATION_XML_VALUE) @ResponseBody public User post(@RequestBody User user){ logger.info(user.toString()); return user; } @RequestMapping(path = "/get",method = Req... |
### Question:
XmlController { @RequestMapping(path = "/postHouse",method = RequestMethod.POST,produces = MediaType.APPLICATION_XML_VALUE,consumes = MediaType.APPLICATION_XML_VALUE) @ResponseBody public House postHouse(@RequestBody House house){ logger.info(house.toString()); return house; } @RequestMapping(path = "/ge... |
### Question:
ValidController { @RequestMapping(path = "/post",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public User post(@RequestBody @Valid User user){ return user; } @RequestMapping(path = "/post",method = RequestMeth... |
### Question:
ModelRef { static public boolean validateId(String id){ return (id != null) && (id).matches(REGEX_ID); } ModelRef(ModelRef modelRef); ModelRef(Principal owner, String id); @Override int hashCode(); @Override boolean equals(Object object); Principal getOwner(); String getId(); static boolean validateId(St... |
### Question:
CsvUtil { static public CsvPreference getFormat(String delimiterChar, String quoteChar){ char delimiter = ','; char quote = '\"'; if(delimiterChar != null){ delimiterChar = decodeDelimiter(delimiterChar); if(delimiterChar.length() != 1){ throw new IllegalArgumentException("Invalid CSV delimiter character:... |
### Question:
WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> { @Override public Response toResponse(WebApplicationException exception){ Response response = exception.getResponse(); Throwable throwable = exception; Map<Throwable, Throwable> throwableMap = new IdentityHashMap<>(); while... |
### Question:
Decorating { public static <T> DecoratingWith<T> proxy(final Class<T> type) { return new DecoratingWith<T>(new Decorating<T, T>((T)null, type)); } private Decorating(final U delegate, final Class<T>primaryType, final Class<?>... types); static DecoratingWith<T> proxy(final Class<T> type); static Decorati... |
### Question:
Privileging { public static <T> PrivilegingWith<T> proxy(Class<T> type) { return new PrivilegingWith<T>(new Privileging<T>(type)); } private Privileging(Class<T> type); static PrivilegingWith<T> proxy(Class<T> type); static PrivilegingExecutedByOrBuild<T> proxy(T target); }### Answer:
@Test public void ... |
### Question:
Failover { public static <T> FailoverWithOrExceptingOrBuild<T> proxy(Class<T> type) { return new FailoverWithOrExceptingOrBuild<T>(new Failover<T>(type)); } private Failover(Class<T> primaryType, Class<?>... types); static FailoverWithOrExceptingOrBuild<T> proxy(Class<T> type); static FailoverWithOrExcep... |
### Question:
Delegating { public static <T> DelegatingWith<T> proxy(Class<T> type) { return new DelegatingWith<T>(new Delegating<T>(type)); } private Delegating(Class<T> type); static DelegatingWith<T> proxy(Class<T> type); }### Answer:
@Test public void shouldSupportIndirectRecursion() { Faculty fac = new Faculty()... |
### Question:
Echoing { public static <T> EchoingWithOrTo<T> proxy(final Class<T> type) { return new EchoingWithOrTo<T>(new Echoing<T>(type)); } private Echoing(final Class<T> type); static EchoingWithOrTo<T> proxy(final Class<T> type); }### Answer:
@Test public void shouldEchoMethodNameAndArgs() throws Exception { W... |
### Question:
CglibProxyFactory extends AbstractProxyFactory { public boolean canProxy(final Class<?> type) { return !Modifier.isFinal(type.getModifiers()); } CglibProxyFactory(); CglibProxyFactory(boolean interceptDuringConstruction); T createProxy(final Invoker invoker, final Class<?>... types); boolean canProxy(fin... |
### Question:
ReflectionUtils { public static Class<?> getMostCommonSuperclass(Object... objects) { Class<?> type = null; boolean found = false; if (objects != null && objects.length > 0) { while (!found) { for (Object object : objects) { found = true; if (object != null) { final Class<?> currenttype = object.getClass(... |
### Question:
ReflectionUtils { public static Set<Class<?>> getAllInterfaces(Object... objects) { final Set<Class<?>> interfaces = new HashSet<Class<?>>(); for (Object object : objects) { if (object != null) { getInterfaces(object.getClass(), interfaces); } } interfaces.remove(InvokerReference.class); return interfaces... |
### Question:
ReflectionUtils { public static void writeMethod(final ObjectOutputStream out, final Method method) throws IOException { out.writeObject(method.getDeclaringClass()); out.writeObject(method.getName()); out.writeObject(method.getParameterTypes()); } private ReflectionUtils(); static Set<Class<?>> getAllInt... |
### Question:
ReflectionUtils { public static Method readMethod(final ObjectInputStream in) throws IOException, ClassNotFoundException { final Class<?> type = Class.class.cast(in.readObject()); final String name = String.class.cast(in.readObject()); final Class<?>[] parameters = Class[].class.cast(in.readObject()); try... |
### Question:
Future { public static <T> FutureWith<T> proxy(Class<T> primaryType) { Future<T> future = new Future<T>(new Class<?>[]{primaryType}); return new FutureWith<T>(future); } private Future(Class<?>[] types); static FutureWith<T> proxy(Class<T> primaryType); static FutureWith<T> proxy(Class<T> primaryType, Cl... |
### Question:
RRestoreBlobStrategy extends BaseRestoreBlobStrategy<RRestoreBlobData> { @Override protected RRestoreBlobData createRestoreData(final RestoreBlobData restoreBlobData) { checkState(!isEmpty(restoreBlobData.getBlobName()), "Blob name cannot be empty"); return new RRestoreBlobData(restoreBlobData); } @Inject... |
### Question:
RRestoreBlobStrategy extends BaseRestoreBlobStrategy<RRestoreBlobData> { @Nonnull @Override protected List<HashAlgorithm> getHashAlgorithms() { return ImmutableList.of(SHA1); } @Inject RRestoreBlobStrategy(final NodeAccess nodeAccess,
final RepositoryManager repositoryManage... |
### Question:
RRestoreBlobStrategy extends BaseRestoreBlobStrategy<RRestoreBlobData> { @Override protected String getAssetPath(@Nonnull final RRestoreBlobData rRestoreBlobData) { return rRestoreBlobData.getBlobData().getBlobName(); } @Inject RRestoreBlobStrategy(final NodeAccess nodeAccess,
... |
### Question:
RRestoreBlobStrategy extends BaseRestoreBlobStrategy<RRestoreBlobData> { @Override protected boolean assetExists(@Nonnull final RRestoreBlobData rRestoreBlobData) { RRestoreFacet facet = getRestoreFacet(rRestoreBlobData); return facet.assetExists(getAssetPath(rRestoreBlobData)); } @Inject RRestoreBlobStr... |
### Question:
RRestoreBlobStrategy extends BaseRestoreBlobStrategy<RRestoreBlobData> { @Override protected boolean componentRequired(final RRestoreBlobData data) { RRestoreFacet facet = getRestoreFacet(data); final String path = data.getBlobData().getBlobName(); return facet.componentRequired(path); } @Inject RRestore... |
### Question:
RRestoreBlobStrategy extends BaseRestoreBlobStrategy<RRestoreBlobData> { @Override protected Query getComponentQuery(final RRestoreBlobData data) throws IOException { RRestoreFacet facet = getRestoreFacet(data); RestoreBlobData blobData = data.getBlobData(); Map<String, String> attributes; try (InputStrea... |
### Question:
XssSanitizerService { public String sanitize(String html) { return policyFactory.sanitize( html, xssHtmlChangeListener, "ip='"+ getIpAddressFromRequestContext()+"'" ); } String sanitize(String html); }### Answer:
@Test public void test() throws Exception { String unsafe = "<a href='javascript:alert('XSS... |
### Question:
SettingsController { @GetMapping(API+CONFIG) public SettingsDTO getConfig(@AuthenticationPrincipal UserAccountDetailsDTO userAccount){ Iterable<RuntimeSettings> runtimeSettings = runtimeSettingsRepository.findAll(); SettingsDTO settingsDTOPartial = StreamSupport.stream(runtimeSettings.spliterator(), false... |
### Question:
PostController { @PreAuthorize("@blogSecurityService.hasPostPermission(#userAccount, T(com.github.nkonev.blog.security.permissions.PostPermissions).CREATE)") @PostMapping(Constants.Urls.API + Constants.Urls.POST) public PostDTOWithAuthorization addPost( @AuthenticationPrincipal UserAccountDetailsDTO userA... |
### Question:
PostConverter { public static String getYouTubeVideoId(String iframeSrcUrl) { UriComponents build = UriComponentsBuilder.fromHttpUrl(iframeSrcUrl).build(); List<String> pathSegments = build.getPathSegments(); return pathSegments.get(pathSegments.size() - 1); } PostDTOWithAuthorization convertToDto(Post s... |
### Question:
PostConverter { String getTitleImg(PostDTO postDTO) { String titleImg = postDTO.getTitleImg(); if (setFirstImageAsTitle && StringUtils.isEmpty(titleImg)) { try { Document document = Jsoup.parse(postDTO.getText()); Elements images = document.getElementsByTag("img"); if (!images.isEmpty()) { Element element... |
### Question:
JettyServerWrapper extends Server { HttpServiceContext getOrCreateContext(final Model model) { return getOrCreateContext(model.getContextModel()); } JettyServerWrapper(ServerModel serverModel, ThreadPool threadPool); HandlerCollection getRootHandlerCollection(); void configureContext(final Map<String, Obj... |
### Question:
Path { static String replaceSlashes(final String target) { String replaced = target; if (replaced != null) { replaced = replaced.replaceAll("/+", "/"); } return replaced; } private Path(); static String normalizeResourcePath(final String path); static String getDirectParent(URL entry); }### Answer:
@Tes... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.