method2testcases stringlengths 118 6.63k |
|---|
### Question:
AvUtil extends GpCoreUtil { public static String fixBrokenBgColor(String oldHtml) { return oldHtml.replaceAll("color\\s?=\\s?[\",']([0-9,a-f,A-F]{6})[\",']", "#$1"); } static String fixBrokenBgColor(String oldHtml); static boolean fixBrokenBgColor(File oldHtml); }### Answer:
@Test public void testFixBro... |
### Question:
AVSwingUtil extends GpCoreUtil { public static File createLocalCopyFromURL(final Component owner, final URL url, String title, final String postFix) throws IOException { if (!url.toString().contains("jar:") && (url.toString().contains("file"))) { LOGGER.debug("Not copying the URL to temp file because we a... |
### Question:
JNLPSwingUtil extends JNLPUtil { public static void loadPartAndCreateDialogForIt( AtlasStatusDialogInterface asg, final String... parts) { try { if (GraphicsEnvironment.isHeadless()) { loadPart(parts, new NoGuiDownloadServiceListener()); return; } boolean edt = SwingUtilities.isEventDispatchThread(); LOGG... |
### Question:
DpLayerVectorFeatureSourceShapefileEd extends
DpLayerVectorFeatureSourceShapefile implements DpEditableInterface { private void parseGeocommonsReadme(URL geocommonsReadmeURL, int phase) { try { InputStream openStream = geocommonsReadmeURL.openStream(); try { InputStreamReader inStream = new InputStreamR... |
### Question:
UniqueValuesAddGUI extends CancellableDialogAdapter { public UniqueValuesAddGUI(Component owner, final UniqueValuesRulesListInterface<VALUETYPE> rulesList) { super(owner); this.rulesList = rulesList; initialize(); String title = ASUtil.R("UniqueValuesRuleList.AddAllValues.SearchingMsg"); final AtlasStatus... |
### Question:
SymbolSelectorGUI extends AtlasDialog { public SymbolSelectorGUI(Component owner, AtlasStylerVector asv, String title, final SingleRuleList singleSymbolRuleList) { super(owner); if (asv == null) throw new IllegalStateException("asv may not be null here!"); this.asv = asv; if (title != null) setTitle(title... |
### Question:
FeatureClassificationGUI extends ClassificationGUI { private AtlasStylerVector getAtlasStyler() { return (AtlasStylerVector) atlasStyler; } FeatureClassificationGUI(Component owner,
FeatureClassification classifier, AtlasStylerVector atlasStyler,
String title); FeatureClassification getClassifier();... |
### Question:
TextLabelingClassLanguageSelectorDialog extends
CancellableDialogAdapter { public TextLabelingClassLanguageSelectorDialog(Component parentGui, TextRuleList rulesList) { super(parentGui, ASUtil .R("TextSymbolizerClass.CreateALanguageDefault.DialogTitle")); this.rulesList = rulesList; lcb = new LanguagesC... |
### Question:
LineSymbolEditGUI extends AbstractStyleEditGUI { public LineSymbolEditGUI(final AtlasStylerVector asv, final org.geotools.styling.LineSymbolizer symbolizer) { super(asv); this.symbolizer = symbolizer; initialize(); } LineSymbolEditGUI(final AtlasStylerVector asv, final org.geotools.styling.LineSymbolizer ... |
### Question:
PolygonSymbolEditGUI extends AbstractStyleEditGUI { public PolygonSymbolEditGUI(final AtlasStylerVector asv, final org.geotools.styling.PolygonSymbolizer symbolizer) { super(asv); this.symbolizer = symbolizer; initialize(); } PolygonSymbolEditGUI(final AtlasStylerVector asv,
final org.geotools.styling... |
### Question:
AtlasStylerPane extends JSplitPane implements ClosableSubwindows { public AtlasStylerPane(StylerDialog stylerDialog) { this.asd = stylerDialog; this.atlasStyler = stylerDialog.getAtlasStyler(); initialize(); atlasStyler.setQuite(true); { for (AbstractRulesList ruleList : atlasStyler.getRuleLists()) { crea... |
### Question:
AddRulesListDialog extends AtlasDialog implements Cancellable { public AddRulesListDialog(Component owner, AtlasStyler atlasStyler) { super(owner, ASUtil.R("AddRulesListDialog.title", atlasStyler.getTitle())); this.owner = owner; this.atlasStyler = atlasStyler; jComboBoxRuleListType = new RulesListJComboB... |
### Question:
DpEntryFactory { public static DpEntry create(AtlasConfigEditable ace, File file, Component owner) throws AtlasImportException { for (DpEntryTesterInterface test : testers) { if (test.test(owner, file)) return test.create(ace, file, owner); } return null; } private DpEntryFactory(); static DpEntry create... |
### Question:
TextSymbolizerEditGUI extends AbstractStyleEditGUI { public JComboBox getJComboBoxFont() { if (jComboBoxFont == null) { jComboBoxFont = new JComboBox(); List<Literal>[] fontFamilies = asv.getAvailableFonts(); jComboBoxFont.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellR... |
### Question:
GraphicEditGUI extends AbstractStyleEditGUI { public GraphicEditGUI(final AtlasStylerVector asv, final Graphic graphic_, GeometryForm geomForm) { super(asv); this.geometryForm = geomForm; if (graphic_ != null) { this.graphic = graphic_; } else { this.graphic = StylingUtil.STYLE_BUILDER.createGraphic(); fi... |
### Question:
SVGSelector extends CancellableDialogAdapter { public void changeURL(URL newUrl) { url = newUrl; LOGGER.debug("Changing " + this.getClass().getSimpleName() + " URL to " + url.getFile()); jList = null; rescan(false); jScrollPane1.setViewportView(getJList()); jTextFieldURL.setText(url.getFile()); jButtonUp.... |
### Question:
GPProps { protected static void init(final String propertiesFilename, final String appDirname) { GpUtil.initGpLogging(); GPProps.propertiesFilename = propertiesFilename; GPProps.appDirname = appDirname; try { final FileInputStream inStream = new FileInputStream( getPropertiesFile()); try { properties.load... |
### Question:
GpUtil { public static void initBugReporting() { ExceptionDialog.setMailDestinationAddress("tzeggai@wikisquare.de"); ExceptionDialog.setSmtpMailer(bugReportMailer); ExceptionDialog.addAdditionalAppInfo(ReleaseUtil .getVersionInfo(GpUtil.class)); } static void initGpLogging(); static void initBugReporting... |
### Question:
GpUtil { public static void initGpLogging() throws FactoryConfigurationError { if (Logger.getRootLogger().getAllAppenders().hasMoreElements()) return; DOMConfigurator.configure(GPProps.class .getResource("/geopublishing_log4j.xml")); Logger.getRootLogger().addAppender( Logger.getLogger("dummy").getAppende... |
### Question:
AMLExporter { protected Node exportFonts(Document document) { final Element fontsElement = document.createElementNS(AMLUtil.AMLURI, AMLUtil.TAG_FONTS); File fontsDir = getAce().getFontsDir(); Collection<File> listFiles = FileUtils.listFiles(fontsDir, GpUtil.FontsFilesFilter, FilterUtil.BlacklistedFoldersF... |
### Question:
AMLExporter { public File writeBuildxml(File targetDir, String atlasBaseName) { if (atlasBaseName == null || atlasBaseName.equals(AtlasConfig.DEFAULTBASENAME) || atlasBaseName.equals("null")) { LOGGER.info("Not writing a build.xml for automatic publishing, because the basename is " + atlasBaseName + ". Pl... |
### Question:
ASProps { protected static void init(String propertiesFilename, String appDirname) { ASProps.propertiesFilename = propertiesFilename; ASProps.appDirname = appDirname; try { properties.load(new FileInputStream(getPropertiesFile())); } catch (FileNotFoundException e) { } catch (IOException e) { LOGGER.error... |
### Question:
FeatureClassification extends Classification { public StyledFeaturesInterface<?> getStyledFeatures() { return styledFeatures; } FeatureClassification(final StyledFeaturesInterface<?> styledFeatures); FeatureClassification(
final StyledFeaturesInterface<?> styledFeatures,
final String value_field_na... |
### Question:
TextRuleList extends AbstractRulesList { public static Filter classLanguageFilter(String lang) { if (lang == null) lang = XMapPane.ENV_LANG_DEFAULT; Expression exEnv = ff.function("env", ff.literal(XMapPane.ENV_LANG), ff.literal(XMapPane.ENV_LANG_DEFAULT)); Filter filter = ff.equals(ff.literal(lang), exEn... |
### Question:
TextRuleList extends AbstractRulesList { public boolean existsClass(Filter filter, String lang) { for (int i = 0; i < countClasses(); i++) { if (getClassLang(i) == null && lang != null) continue; if (getClassLang(i) != null && !getClassLang(i).equals(lang)) continue; if (filter != null && getClassFilter(i... |
### Question:
RasterRulesList_DistinctValues extends RasterRulesListColormap implements UniqueValuesRulesListInterface<Double> { @Override public void importColorMap(ColorMap cm) { QuantileBin1D ops = new QuantileBin1D(1.); for (ColorMapEntry cme : cm.getColorMapEntries()) { importValuesLabelsQuantitiesColors(cme); ops... |
### Question:
RasterRulesListColormap extends RasterRulesList { @Override public void importRules(List<Rule> rules) { pushQuite(); try { if (rules.size() > 1) { LOGGER.warn("Importing a " + this.getClass().getSimpleName() + " with " + rules.size() + " rules"); } Rule rule = rules.get(0); RasterSymbolizer rs = (RasterSy... |
### Question:
BooleanConverter extends DefaultObjectConverter<Boolean> { @Override public String toString(Boolean object, ConverterContext context) { if (Boolean.FALSE.equals(object)) { return getFalse(); } else if (Boolean.TRUE.equals(object)) { return getTrue(); } else { return getNull(); } } BooleanConverter(); @Ove... |
### Question:
BooleanConverter extends DefaultObjectConverter<Boolean> { @Override public Boolean fromString(String string, ConverterContext context) { if (string.equalsIgnoreCase(getTrue())) { return Boolean.TRUE; } else if (string.equalsIgnoreCase("true")) { return Boolean.TRUE; } else if (string.equalsIgnoreCase(get... |
### Question:
LocalDateConverter extends TemporalAccessConverter<LocalDate> { synchronized public LocalDate fromString(String string, String pattern) { return LocalDate.from(DateTimeFormatter.ofPattern(pattern).parse(string)); } LocalDateConverter(); synchronized LocalDate fromString(String string, String pattern); @Ov... |
### Question:
PercentConverter extends DoubleConverter { @Override public Double fromString(String string, ConverterContext context) { Number number = numberFromString(string, context); if (number == null) { number = Double.parseDouble(string); } if (string != null && !string.trim().endsWith("%") && number != null) { n... |
### Question:
DecorationPane extends StackPane implements DecorationSupport { public Parent getContent() { return _content; } DecorationPane(); DecorationPane(Parent content); Parent getContent(); void setContent(Parent content); @Override void positionInArea(Node child, double areaX, double areaY, double areaWidth, d... |
### Question:
HelloWorld { public void setPhrase( String phrase ) throws IllegalArgumentException { if( phrase == null ) { throw new IllegalArgumentException( "Phrase may not be null " ); } this.phrase = phrase; } String getPhrase(); void setPhrase( String phrase ); String getName(); void setName( String name ); Strin... |
### Question:
QueryBuilderFactoryImpl implements QueryBuilderFactory { @Override public <T> QueryBuilder<T> newQueryBuilder( final Class<T> resultType ) { NotQueryableException.throwIfNotQueryable( resultType ); final ServiceReference<EntityFinder> serviceReference; try { serviceReference = finder.findService( EntityFi... |
### Question:
UsageGraph { public List<K> resolveOrder() throws BindingException { if( resolved == null ) { buildUsageGraph(); resolved = new LinkedList<>(); for( K item : data ) { int pos = resolved.size(); for( K entry : resolved ) { if( transitiveUse( entry, item ) ) { pos = resolved.indexOf( entry ); break; } } res... |
### Question:
UsageGraph { public boolean transitiveUse( K source, K other ) throws BindingException { if( transitive == null ) { buildUsageGraph(); } return transitive.containsKey( source ) && transitive.get( source ).contains( other ); } UsageGraph( Collection<K> data, Use<K> use, boolean allowCyclic ); boolean trans... |
### Question:
ValueBuilderTemplate { public T newInstance( ModuleDescriptor module ) { ValueBuilder<T> builder = module.instance().newValueBuilder( type ); build( builder.prototype() ); return builder.newInstance(); } protected ValueBuilderTemplate( Class<T> type ); T newInstance( ModuleDescriptor module ); }### Answ... |
### Question:
Classes { public static Stream<? extends Type> interfacesOf( Stream<? extends Type> types ) { return types.flatMap( INTERFACES_OF ); } private Classes(); static Type typeOf( AccessibleObject from ); static Stream<Type> typesOf( Stream<? extends Type> types ); static Stream<? extends Type> typesOf( Type t... |
### Question:
Classes { @SuppressWarnings( "raw" ) public static Set<Class<?>> interfacesWithMethods( Set<Class<?>> interfaces ) { Set<Class<?>> newSet = new LinkedHashSet<>(); for( Class type : interfaces ) { if( type.isInterface() && type.getDeclaredMethods().length > 0 ) { newSet.add( type ); } } return newSet; } pr... |
### Question:
Classes { @SuppressWarnings( "raw" ) public static String toURI( final Class clazz ) throws NullPointerException { return toURI( clazz.getName() ); } private Classes(); static Type typeOf( AccessibleObject from ); static Stream<Type> typesOf( Stream<? extends Type> types ); static Stream<? extends Type> ... |
### Question:
Classes { public static String toClassName( String uri ) throws NullPointerException { uri = uri.substring( "urn:polygene:type:".length() ); uri = denormalizeURIToClass( uri ); return uri; } private Classes(); static Type typeOf( AccessibleObject from ); static Stream<Type> typesOf( Stream<? extends Type... |
### Question:
HelloWorld { public void setName( String name ) throws IllegalArgumentException { if( name == null ) { throw new IllegalArgumentException( "Name may not be null " ); } this.name = name; } String getPhrase(); void setPhrase( String phrase ); String getName(); void setName( String name ); String say(); }#... |
### Question:
Classes { @SuppressWarnings( "raw" ) public static Type resolveTypeVariable( TypeVariable name, Class declaringClass, Class topClass ) { Type type = resolveTypeVariable( name, declaringClass, new HashMap<>(), topClass ); if( type == null ) { type = Object.class; } return type; } private Classes(); static... |
### Question:
Collectors { public static <T> Collector<T, ?, T> single() throws IllegalArgumentException { Supplier<T> thrower = () -> { throw new IllegalArgumentException( "No or more than one element in stream" ); }; return java.util.stream.Collectors.collectingAndThen( java.util.stream.Collectors.reducing( ( a, b ) ... |
### Question:
Collectors { public static <T> Collector<T, ?, Optional<T>> singleOrEmpty() { return java.util.stream.Collectors.reducing( ( left, right ) -> { if( left != null && right != null ) { throw new IllegalArgumentException( "More than one element in stream" ); } if( left != null ) { return left; } return right;... |
### Question:
Collectors { public static <T extends Map.Entry<K, U>, K, U> Collector<T, ?, Map<K, U>> toMap() { return toMap( Map.Entry::getKey, Map.Entry::getValue, HashMap::new ); } private Collectors(); static Collector<T, ?, T> single(); static Collector<T, ?, Optional<T>> singleOrEmpty(); static Collector<T, ?, M... |
### Question:
Collectors { public static <T extends Map.Entry<K, U>, K, U> Collector<T, ?, Map<K, U>> toMapWithNullValues() { return toMapWithNullValues( Map.Entry::getKey, Map.Entry::getValue, HashMap::new ); } private Collectors(); static Collector<T, ?, T> single(); static Collector<T, ?, Optional<T>> singleOrEmpty... |
### Question:
UnitOfWorkTemplate { @SuppressWarnings( "unchecked" ) public RESULT withModule( Module module ) throws ThrowableType, UnitOfWorkCompletionException { int loop = 0; ThrowableType ex = null; do { UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( usecase ); try { RESULT result = withUnitOfWork( uow ... |
### Question:
HasTypesCollectors { public static <T extends HasTypes> Collector<T, ?, List<T>> matchingTypes( T hasTypes ) { return hasTypesToListCollector( hasTypes, new HasAssignableFromType<>( hasTypes ) ); } private HasTypesCollectors(); static Collector<T, ?, Optional<T>> matchingType( T hasTypes ); static Collec... |
### Question:
HasTypesCollectors { public static <T extends HasTypes> Collector<T, ?, List<T>> closestTypes( T hasTypes ) { return hasTypesToListCollector( hasTypes, new HasAssignableToType<>( hasTypes ) ); } private HasTypesCollectors(); static Collector<T, ?, Optional<T>> matchingType( T hasTypes ); static Collector... |
### Question:
QualifiedName implements Comparable<QualifiedName> { public String type() { return typeName.normalized(); } QualifiedName( TypeName typeName, String name ); static QualifiedName fromAccessor( AccessibleObject method ); static QualifiedName fromClass( Class type, String name ); static QualifiedName fromNam... |
### Question:
QualifiedName implements Comparable<QualifiedName> { public static QualifiedName fromFQN( String fullQualifiedName ) { Objects.requireNonNull( fullQualifiedName, "qualifiedName" ); int idx = fullQualifiedName.lastIndexOf( ":" ); if( idx == -1 ) { throw new IllegalArgumentException( "Name '" + fullQualifie... |
### Question:
QualifiedName implements Comparable<QualifiedName> { public static QualifiedName fromAccessor( AccessibleObject method ) { Objects.requireNonNull( method, "method" ); return fromClass( ( (Member) method ).getDeclaringClass(), ( (Member) method ).getName() ); } QualifiedName( TypeName typeName, String name... |
### Question:
QualifiedName implements Comparable<QualifiedName> { public static QualifiedName fromClass( Class type, String name ) { return new QualifiedName( TypeName.nameOf( type ), name ); } QualifiedName( TypeName typeName, String name ); static QualifiedName fromAccessor( AccessibleObject method ); static Qualifi... |
### Question:
ScriptMixin implements InvocationHandler, ScriptReloadable, ScriptRedirect, ScriptAttributes, ScriptAttributes.All { @Override public Object invoke( Object proxy, Method method, Object[] objects ) throws Throwable { Object result = ( (Invocable) engine ).invokeFunction( method.getName(), objects ); return... |
### Question:
EntityTypeSerializer { public EntityTypeSerializer() { dataTypes.put( String.class.getName(), XMLSchema.STRING ); dataTypes.put( Integer.class.getName(), XMLSchema.INT ); dataTypes.put( Boolean.class.getName(), XMLSchema.BOOLEAN ); dataTypes.put( Byte.class.getName(), XMLSchema.BYTE ); dataTypes.put( BigD... |
### Question:
SendMail { public void sendSimpleMail(String subject, String to, String context) { SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setFrom(from); simpleMailMessage.setTo(to); simpleMailMessage.setSubject(subject); simpleMailMessage.setText(context); try { javaMailSender.se... |
### Question:
SendMail { public void sendtemplateHtmlMail(String subject, String to, String name) { MimeMessage mimeMessage = javaMailSender.createMimeMessage(); try { MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); helper.setSubject(subject); helper.setTo(to); helper.setFrom(from); String filepath... |
### Question:
ObservationPoint implements AsyncGeolocate.MLSLocationGetterCallback { public void setCounts(MLSJSONObject ichnaeaQueryObj) { mCellCount = ichnaeaQueryObj.getCellCount(); mWifiCount = ichnaeaQueryObj.getWifiCount(); } ObservationPoint(Location pointGPS); ObservationPoint(String provider, Coordinate point... |
### Question:
MapFragment extends android.support.v4.app.Fragment implements MetricsView.IMapLayerToggleListener { public void mapNetworkConnectionChanged() { FragmentActivity activity = getActivity(); if (activity == null) { return; } if (activity.getFilesDir() == null) { showMapNotAvailableMessage(NoMapAvailableMessa... |
### Question:
SerializableTile { public byte[] getTileData() { return (tData == null)? new byte[0] : tData; } SerializableTile(File sTileFile); SerializableTile(byte[] tileBytes, String etag); static String bytesToHex(byte[] bytes); byte[] getTileData(); void setTileData(byte[] tileData); void clearHeaders(); Map<Stri... |
### Question:
DateConverterUtils { public static Date convert2Date(LocalDate localDate) { if (localDate == null) { return null; } return convert2Date(localDate.atStartOfDay()); } private DateConverterUtils(); static Date convert2Date(LocalDate localDate); static Date convert2Date(LocalDateTime localDateTime); static L... |
### Question:
Base64Utils { public static String encode(byte[] data) { if (data == null) { return null; } return Base64.getEncoder().encodeToString(data); } private Base64Utils(); static String encode(byte[] data); static String encode(String data); static String decode(byte[] data); static String decode(String data);... |
### Question:
Base64Utils { public static String decode(byte[] data) { if (data == null) { return null; } try { return new String(Base64.getDecoder().decode(data)); } catch (IllegalArgumentException ex) { return null; } } private Base64Utils(); static String encode(byte[] data); static String encode(String data); stat... |
### Question:
CookieSpecBuilder { public String build() { List<String> builder = new ArrayList<>(); builder.add(String.format("%s=%s", getKey(), getValue())); if (hasText(getPath())) { builder.add(String.format("Path=%s", getPath())); } if (Objects.equals(Boolean.TRUE, getHttpOnly())) { builder.add("HttpOnly"); } if (h... |
### Question:
QuerystringBuilder { public String build() { return getParams().entrySet() .stream() .map(param -> param.getKey() + "=" + encode(param.getValue())) .collect(Collectors.joining("&")); } QuerystringBuilder addParameter(String name, String value); String build(); }### Answer:
@Test public void shouldBeEmpt... |
### Question:
DefaultUUIDGenerator implements UUIDGenerator { @Override public String generate() { return UUID.randomUUID().toString(); } @Override String generate(); }### Answer:
@Test public void test() { String output = generator.generate(); int expected = 36; assertThat(output.length()).isEqualTo(expected); } |
### Question:
DefaultIdGenerator implements IdGenerator { @Override public String generate() { return ObjectId.get().toString(); } @Override String generate(); }### Answer:
@Test public void test() { String output = generator.generate(); int expected = 24; assertThat(output.length()).isEqualTo(expected); } |
### Question:
DefaultUserDetails implements UserDetails { @Override public Collection<? extends GrantedAuthority> getAuthorities() { return authorities().stream() .map(SimpleGrantedAuthority::new) .collect(Collectors.toList()); } @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override String getPa... |
### Question:
DefaultUserDetails implements UserDetails { @Override public boolean isAccountNonExpired() { return true; } @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override String getPassword(); @Override String getUsername(); @Override boolean isAccountNonExpired(); @Override boolean isAccou... |
### Question:
DefaultUserDetails implements UserDetails { @Override public boolean isAccountNonLocked() { return true; } @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override String getPassword(); @Override String getUsername(); @Override boolean isAccountNonExpired(); @Override boolean isAccoun... |
### Question:
DefaultUserDetails implements UserDetails { @Override public boolean isCredentialsNonExpired() { return true; } @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override String getPassword(); @Override String getUsername(); @Override boolean isAccountNonExpired(); @Override boolean isA... |
### Question:
DefaultUserDetails implements UserDetails { @Override public boolean isEnabled() { return true; } @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override String getPassword(); @Override String getUsername(); @Override boolean isAccountNonExpired(); @Override boolean isAccountNonLocke... |
### Question:
DefaultUserDetails implements UserDetails { @Override public int hashCode() { int hash = 5; return 89 * hash + Objects.hashCode(this.username); } @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override String getPassword(); @Override String getUsername(); @Override boolean isAccountN... |
### Question:
DefaultUserDetails implements UserDetails { @Override public boolean equals(Object obj) { return ObjectEquals.of(this) .equals(obj, (orgin, other) -> Objects.equals(orgin.getUsername(), other.getUsername())); } @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override String getPasswor... |
### Question:
SHA384Hashing extends AbstractHashing { @Override public String hash(byte[] data) { try { if (isEmpty(data)) { return null; } MessageDigest digest = MessageDigest.getInstance("SHA-384"); return new String(Hex.encode(digest.digest(data))); } catch (NoSuchAlgorithmException ex) { LOG.warn(null, ex); return ... |
### Question:
ShortHashing extends AbstractHashing { @Override public String hash(byte[] data) { return subString(hashing.hash(data)); } ShortHashing(Hashing hashing, int length); @Override String hash(byte[] data); }### Answer:
@Test public void sholdBe32Characters() { String input = "Hello World"; String output = sh... |
### Question:
CustomSession implements ExpiringSession, Serializable { @Override public int getMaxInactiveIntervalInSeconds() { return this.maxInactiveInterval; } CustomSession(); CustomSession(int maxInactiveInterval); void setMaxInactiveInterval(int interval); @Override void setMaxInactiveIntervalInSeconds(int inter... |
### Question:
CustomSession implements ExpiringSession, Serializable { public Map<String, Object> getAttributes() { return new HashMap<>(this.attributes); } CustomSession(); CustomSession(int maxInactiveInterval); void setMaxInactiveInterval(int interval); @Override void setMaxInactiveIntervalInSeconds(int interval); ... |
### Question:
CustomSession implements ExpiringSession, Serializable { @Override public boolean isExpired() { return isExpired(convert2Timestamp(now())); } CustomSession(); CustomSession(int maxInactiveInterval); void setMaxInactiveInterval(int interval); @Override void setMaxInactiveIntervalInSeconds(int interval); @... |
### Question:
DateConverterUtils { public static LocalDate convert2LocalDate(Date date) { if (date == null) { return null; } return convert2LocalDateTime(date).toLocalDate(); } private DateConverterUtils(); static Date convert2Date(LocalDate localDate); static Date convert2Date(LocalDateTime localDateTime); static Loc... |
### Question:
DateConverterUtils { public static LocalDateTime convert2LocalDateTime(Date date) { if (date == null) { return null; } return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); } private DateConverterUtils(); static Date convert2Date(LocalDate localDate); static Date convert2Date(LocalDat... |
### Question:
ProductService { public void classicalDelete(Long id) { authService.checkAccess(); System.out.println("Delete Product."); } void insert(Product product); void classicalDelete(Long id); void baseAopDelete(Long id); @AdminOnly void annoAopDelete(Long id); }### Answer:
@Test(expected = Exception.class) pub... |
### Question:
ProductService { public void baseAopDelete(Long id) { System.out.println("Delete Product."); } void insert(Product product); void classicalDelete(Long id); void baseAopDelete(Long id); @AdminOnly void annoAopDelete(Long id); }### Answer:
@Test public void baseAopDelete() throws Exception { CurrentUserHo... |
### Question:
ProductService { @AdminOnly public void annoAopDelete(Long id) { System.out.println("Delete Product."); } void insert(Product product); void classicalDelete(Long id); void baseAopDelete(Long id); @AdminOnly void annoAopDelete(Long id); }### Answer:
@Test(expected = Exception.class) public void annoAopDe... |
### Question:
CaseStudy { public static void demonstrate() { String code = "The code"; Course course = Courses.findByCode(code); Lecturer lecturer = course.getLecturer(); String name = lecturer.getName(); System.out.println(name); } static void demonstrate(); }### Answer:
@Test public void demonstrateTest() { CaseStu... |
### Question:
App { public static double mean(List<Double> numbers) { double sum = 0; for (double f : numbers) { sum += f; } return sum / numbers.size(); } static void main(String[] args); static List<Double> compute(); static List<Double> loadFromFile(String filepath); static double mean(List<Double> numbers); static... |
### Question:
App { public static double std(List<Double> numbers, double mean) { double sumSquare = 0; for (double f : numbers) { double diff = f - mean; sumSquare += diff * diff; } return Math.sqrt(sumSquare / numbers.size()); } static void main(String[] args); static List<Double> compute(); static List<Double> load... |
### Question:
App { public static List<Double> compute() throws FileNotFoundException { File file = new File("data"); List<Double> normalized = new ArrayList<>(); Scanner scanner = new Scanner(file); List<Double> numbers = new ArrayList<>(); while (scanner.hasNextDouble()) { double number = scanner.nextDouble(); number... |
### Question:
RecursiveFibonacci { @Requires("0 <= n") @Ensures("0 <= result") public int apply(int n) { if (0 == n || 1 == n) { return n; } else { return apply(n - 1) + apply(n - 2); } } @Requires("0 <= n") @Ensures("0 <= result") int apply(int n); }### Answer:
@Test(expected = PreconditionError.class) public void f... |
### Question:
App { public String getGreeting() { return "Hello world."; } String getGreeting(); static void main(String[] args); }### Answer:
@Test void appHasAGreeting() { App classUnderTest = new App(); assertNotNull(classUnderTest.getGreeting(), "app should have a greeting"); }
@Test public void testAppHasAGreeti... |
### Question:
Loan { public static Loan createTermLoan(double commitment, int riskTaking, Date maturity){ return new Loan(null, commitment, 0.00, riskTaking, maturity, null); } private Loan(CapitalStrategy capitalStrategy, double commitment, double outstanding, int riskTaking, Date maturity, Date expiry); static Loan ... |
### Question:
Loan { public static Loan createRevolverLoan(double commitment, double outstanding, int customerRating, Date maturity, Date expiry){ return new Loan(null, commitment, outstanding, customerRating, maturity, expiry); } private Loan(CapitalStrategy capitalStrategy, double commitment, double outstanding, int... |
### Question:
App { public static List<Double> compute() throws FileNotFoundException { List<Double> numbers = loadFromFile("data"); double mean = mean(numbers); double std = std(numbers, mean); List<Double> normalized = normalize(numbers, mean, std); System.out.println(normalized); writeToFile(normalized); return norm... |
### Question:
App { public static List<Double> loadFromFile(String filepath) throws FileNotFoundException { File file = new File(filepath); Scanner scanner = new Scanner(file); List<Double> numbers = new ArrayList<>(); while (scanner.hasNextDouble()) { double number = scanner.nextDouble(); numbers.add(number); } scanne... |
### Question:
Utils { public static AudioStream getHighestQualityAudio(List<AudioStream> audioStreams) { int highestQualityIndex = 0; for (int i = 1; i < audioStreams.size(); i++) { AudioStream audioStream = audioStreams.get(i); if (audioStream.avgBitrate > audioStreams.get(highestQualityIndex).avgBitrate) highestQuali... |
### Question:
Utils { public static ArrayList<VideoStream> getSortedStreamVideosList(Context context, List<VideoStream> videoStreams, List<VideoStream> videoOnlyStreams, boolean ascendingOrder) { boolean showHigherResolutions = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string... |
### Question:
OpenJp2ImageWriter extends ImageWriter { @Override public ImageWriteParam getDefaultWriteParam() { return new OpenJp2ImageWriteParam(); } protected OpenJp2ImageWriter(ImageWriterSpi originatingProvider, OpenJpeg lib); @Override void setOutput(Object output); @Override ImageWriteParam getDefaultWriteParam... |
### Question:
TurboJpegImageReader extends ImageReader { @Override public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException { checkIndex(imageIndex); ByteBuffer data = jpegData; try { int rotation = 0; Rectangle region = null; Rectangle extraCrop = null; if (param instanceof TurboJpegImageRead... |
### Question:
Table { Table(LSql lSql, String sqlSchemaAndTableName) { this.lSql = lSql; this.sqlSchemaAndTableName = sqlSchemaAndTableName; fetchMeta(); if (logger.isDebugEnabled()) { StringBuilder msg = new StringBuilder("Read schema for table '" + this.sqlSchemaAndTableName + "':\n"); for (Column column : columns.va... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.