method2testcases
stringlengths
118
3.08k
### Question: LogManagerProperties extends Properties { static void checkLogManagerAccess() { boolean checked = false; final Object m = LOG_MANAGER; if (m != null) { try { if (m instanceof LogManager) { checked = true; ((LogManager) m).checkAccess(); } } catch (final SecurityException notAllowed) { if (checked) { throw...
### Question: CollectorFormatter extends Formatter { @Override public String format(final LogRecord record) { if (record == null) { throw new NullPointerException(); } boolean accepted; do { final LogRecord peek = peek(); LogRecord update = apply(peek != null ? peek : record, record); if (peek != update) { update.getSo...
### Question: LogManagerProperties extends Properties { @Override @SuppressWarnings("CloneDoesntCallSuperClone") public synchronized Object clone() { return exportCopy(defaults); } LogManagerProperties(final Properties parent, final String prefix); @Override @SuppressWarnings("CloneDoesntCallSuperClone") synchronized O...
### Question: DurationFilter implements Filter { @Override public String toString() { boolean idle; boolean loggable; synchronized (this) { final long millis = System.currentTimeMillis(); idle = test(0L, millis); loggable = test(records, millis); } return getClass().getName() + "{records=" + records + ", duration=" + d...
### Question: LogManagerProperties extends Properties { static boolean isReflectionClass(String name) throws Exception { String[] names = REFLECT_NAMES; if (names == null) { REFLECT_NAMES = names = reflectionClassNames(); } for (String rf : names) { if (name.equals(rf)) { return true; } } findClass(name); return false;...
### Question: DurationFilter implements Filter { @Override protected DurationFilter clone() throws CloneNotSupportedException { final DurationFilter clone = (DurationFilter) super.clone(); clone.count = 0L; clone.peak = 0L; clone.start = 0L; return clone; } DurationFilter(); DurationFilter(final long records, final lo...
### Question: DurationFilter implements Filter { @SuppressWarnings("override") public boolean isLoggable(final LogRecord record) { return accept(record.getMillis()); } DurationFilter(); DurationFilter(final long records, final long duration); @Override boolean equals(final Object obj); boolean isIdle(); @Override int ...
### Question: DurationFilter implements Filter { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final DurationFilter other = (DurationFilter) obj; if (this.records != other.records) { return false; } if (this.durat...
### Question: DurationFilter implements Filter { @Override public int hashCode() { int hash = 3; hash = 89 * hash + (int) (this.records ^ (this.records >>> 32)); hash = 89 * hash + (int) (this.duration ^ (this.duration >>> 32)); return hash; } DurationFilter(); DurationFilter(final long records, final long duration); ...
### Question: Response { public String readAtom() { return readDelimString(ATOM_CHAR_DELIM); } Response(String s); Response(String s, boolean supportsUtf8); Response(Protocol p); Response(Response r); static Response byeResponse(Exception ex); boolean supportsUtf8(); void skipSpaces(); boolean isNextNonSpace(char c)...
### Question: Response { public String readAtomString() { return (String)parseString(true, true); } Response(String s); Response(String s, boolean supportsUtf8); Response(Protocol p); Response(Response r); static Response byeResponse(Exception ex); boolean supportsUtf8(); void skipSpaces(); boolean isNextNonSpace(ch...
### Question: Response { public String[] readStringList() { return readStringList(false); } Response(String s); Response(String s, boolean supportsUtf8); Response(Protocol p); Response(Response r); static Response byeResponse(Exception ex); boolean supportsUtf8(); void skipSpaces(); boolean isNextNonSpace(char c); v...
### Question: Protocol { public String writeCommand(String command, Argument args) throws IOException, ProtocolException { String tag = tagPrefix + Integer.toString(tagCounter++); output.writeBytes(tag + " " + command); if (args != null) { output.write(' '); args.write(this); } output.write(CRLF); output.flush(); retur...
### Question: ResponseInputStream { public ByteArray readResponse() throws IOException { return readResponse(null); } ResponseInputStream(InputStream in); ByteArray readResponse(); ByteArray readResponse(ByteArray ba); int available(); }### Answer: @Test public void testEofWhileReadingLiteral() throws Exception { Byte...
### Question: ContentType { public boolean match(ContentType cType) { if (!((primaryType == null && cType.getPrimaryType() == null) || (primaryType != null && primaryType.equalsIgnoreCase(cType.getPrimaryType())))) return false; String sType = cType.getSubType(); if ((subType != null && subType.startsWith("*")) || (sTy...
### Question: MailDateFormat extends SimpleDateFormat { @Override public StringBuffer format(Date date, StringBuffer dateStrBuf, FieldPosition fieldPosition) { return super.format(date, dateStrBuf, fieldPosition); } MailDateFormat(); @Override MailDateFormat clone(); @Override StringBuffer format(Date date, StringBuffe...
### Question: MailDateFormat extends SimpleDateFormat { @Override public void setCalendar(Calendar newCalendar) { throw new UnsupportedOperationException("Method " + "setCalendar() shouldn't be called"); } MailDateFormat(); @Override MailDateFormat clone(); @Override StringBuffer format(Date date, StringBuffer dateStrB...
### Question: MailDateFormat extends SimpleDateFormat { @Override public void setNumberFormat(NumberFormat newNumberFormat) { throw new UnsupportedOperationException("Method " + "setNumberFormat() shouldn't be called"); } MailDateFormat(); @Override MailDateFormat clone(); @Override StringBuffer format(Date date, Strin...
### Question: MailDateFormat extends SimpleDateFormat { @Override public Date get2DigitYearStart() { throw new UnsupportedOperationException("Method " + "get2DigitYearStart() shouldn't be called"); } MailDateFormat(); @Override MailDateFormat clone(); @Override StringBuffer format(Date date, StringBuffer dateStrBuf, ...
### Question: MailDateFormat extends SimpleDateFormat { @Override public void set2DigitYearStart(Date startDate) { throw new UnsupportedOperationException("Method " + "set2DigitYearStart() shouldn't be called"); } MailDateFormat(); @Override MailDateFormat clone(); @Override StringBuffer format(Date date, StringBuffer ...
### Question: MailDateFormat extends SimpleDateFormat { @Override public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) { throw new UnsupportedOperationException("Method " + "setDateFormatSymbols() shouldn't be called"); } MailDateFormat(); @Override MailDateFormat clone(); @Override StringBuffer format(...
### Question: InternetHeaders { public String[] getHeader(String name) { Iterator<InternetHeader> e = headers.iterator(); List<String> v = new ArrayList<>(); while (e.hasNext()) { InternetHeader h = e.next(); if (name.equalsIgnoreCase(h.getName()) && h.line != null) { v.add(h.getValue()); } } if (v.size() == 0) return ...
### Question: InternetHeaders { public void load(InputStream is) throws MessagingException { load(is, false); } InternetHeaders(); InternetHeaders(InputStream is); InternetHeaders(InputStream is, boolean allowutf8); void load(InputStream is); void load(InputStream is, boolean allowutf8); String[] getHeader(String nam...
### Question: URLName { public String getFile() { return file; } URLName( String protocol, String host, int port, String file, String username, String password ); URLName(URL url); URLName(String url); @Override String toString(); int getPort(); String getProtocol(); String getFile(); String getRef(); String g...
### Question: LogManagerProperties extends Properties { @Override public synchronized Object get(final Object key) { Object value; if (key instanceof String) { value = getProperty((String) key); } else { value = null; } if (value == null) { value = defaults.get(key); if (value == null && !defaults.containsKey(key)) { v...
### Question: LogManagerProperties extends Properties { @Override public synchronized boolean containsKey(final Object key) { boolean found = key instanceof String && getProperty((String) key) != null; if (!found) { found = defaults.containsKey(key) || super.containsKey(key); } return found; } LogManagerProperties(fina...
### Question: LogManagerProperties extends Properties { @Override public synchronized Object remove(final Object key) { final Object def = preWrite(key); final Object man = super.remove(key); return man == null ? def : man; } LogManagerProperties(final Properties parent, final String prefix); @Override @SuppressWarning...
### Question: LogManagerProperties extends Properties { @Override public synchronized Object put(final Object key, final Object value) { if (key instanceof String && value instanceof String) { final Object def = preWrite(key); final Object man = super.put(key, value); return man == null ? def : man; } else { return sup...
### Question: LogManagerProperties extends Properties { @Override public Object setProperty(String key, String value) { return this.put(key, value); } LogManagerProperties(final Properties parent, final String prefix); @Override @SuppressWarnings("CloneDoesntCallSuperClone") synchronized Object clone(); @Override synch...
### Question: LogManagerProperties extends Properties { static Filter newFilter(String name) throws Exception { return newObjectFrom(name, Filter.class); } LogManagerProperties(final Properties parent, final String prefix); @Override @SuppressWarnings("CloneDoesntCallSuperClone") synchronized Object clone(); @Override ...
### Question: MailHandler extends Handler { public void postConstruct() { } MailHandler(); MailHandler(final int capacity); MailHandler(final Properties props); @Override boolean isLoggable(final LogRecord record); @Override void publish(final LogRecord record); void postConstruct(); void preDestroy(); void push(); @...
### Question: PropUtil { public static boolean getBooleanProperty(Properties props, String name, boolean def) { return getBoolean(getProp(props, name), def); } private PropUtil(); static int getIntProperty(Properties props, String name, int def); static boolean getBooleanProperty(Properties props, String name, boo...
### Question: SeverityComparator implements Comparator<LogRecord>, Serializable { public final int applyThenCompare(Throwable tc1, Throwable tc2) { return tc1 == tc2 ? 0 : compareThrowable(apply(tc1), apply(tc2)); } Throwable apply(final Throwable chain); final int applyThenCompare(Throwable tc1, Throwable tc2); int c...
### Question: SeverityComparator implements Comparator<LogRecord>, Serializable { static SeverityComparator getInstance() { return (SeverityComparator) INSTANCE; } Throwable apply(final Throwable chain); final int applyThenCompare(Throwable tc1, Throwable tc2); int compareThrowable(final Throwable t1, final Throwable ...
### Question: SeverityComparator implements Comparator<LogRecord>, Serializable { @SuppressWarnings("override") public int compare(final LogRecord o1, final LogRecord o2) { if (o1 == null || o2 == null) { throw new NullPointerException(toString(o1, o2)); } if (o1 == o2) { return 0; } int cmp = compare(o1.getLevel(), o2...
### Question: CompressionEncodingFilter implements EncodingFilter { @Override public boolean applyDecoding(final HttpHeader httpPacket) { if(! httpPacket.isRequest()) { return false; } assert httpPacket instanceof HttpRequestPacket; return canDecompressHttpRequest((HttpRequestPacket) httpPacket, compressionConfig, alia...
### Question: CompositeBuffer implements Buffer { public abstract int bulk(BulkOperation operation); static CompositeBuffer newBuffer(); static CompositeBuffer newBuffer(final MemoryManager memoryManager); static CompositeBuffer newBuffer(final MemoryManager memoryManager, final Buffer... buffers); static ...
### Question: AbstractSupplier implements Observer, Supplier<T> { @Override public void onResume() { this.logger().log(Level.INFO, "On Resume"); dataManager().addObserver(this); this.logger().log(Level.INFO, "Syncstatus: " + this.dataManager().getSyncStatus()); switch (dataManager().getSyncStatus()) { case NOT_SYNCED: ...
### Question: OneDayFilter implements Filter<Transaction> { @Override public boolean shouldBeRemoved(Transaction t) { return getZeroTimeDate(t.booking().getDate()).compareTo(this.day) != 0; } OneDayFilter(Date day); @Override boolean shouldBeRemoved(Transaction t); }### Answer: @Test public void teste_filter_withNotMa...
### Question: ItemCheckedMap implements Filter<Transaction> { public boolean hasItemsChecked() { Boolean ret = false; Iterator iterator = this.map.entrySet().iterator(); while (iterator.hasNext() && !ret) { Map.Entry entry = (Map.Entry) iterator.next(); ret = (Boolean) entry.getValue(); } return ret; } ItemCheckedMap(H...
### Question: ItemCheckedMap implements Filter<Transaction> { public boolean shouldBePresented(String bankAccountID) { return this.map.containsKey(bankAccountID) && this.map.get(bankAccountID).booleanValue(); } ItemCheckedMap(HashMap<String, Boolean> map); boolean hasItemsChecked(); boolean shouldBePresented(String ban...
### Question: ItemCheckedMap implements Filter<Transaction> { @Override public boolean shouldBeRemoved(Transaction t) { if (this.map.isEmpty()) { return false; } boolean shouldStay = shouldBePresented(t.bankAccountID()); return !shouldStay; } ItemCheckedMap(HashMap<String, Boolean> map); boolean hasItemsChecked(); bool...
### Question: AbstractSupplier implements Observer, Supplier<T> { @Override public void addDataListeningObject(DataListening observer) { if (this.dataListenings.isEmpty()) { this.dataManager().addObserver(this); } this.dataListenings.add(observer); } @Override List<T> getAll(); @Override void onResume(); @Override voi...
### Question: BankingDateInformation { public double getAmountDelta() { double amountDelta = 0.0; for (Transaction transaction : this.transactionSupplier.getAll()) { amountDelta += transaction.booking().getAmount(); } return amountDelta; } BankingDateInformation(double amount, Supplier<Transaction> transactionSupplier)...
### Question: SavingsComparator implements Comparator<SavingsAccount> { @Override public int compare(SavingsAccount t1, SavingsAccount t2) { return t1.getFinaldate().compareTo(t2.getFinaldate()); } @Override int compare(SavingsAccount t1, SavingsAccount t2); }### Answer: @Test public void teste_compare_withEqualSavin...
### Question: BankingApiFacade { public List<BankAccessBankingModel> getBankAccesses(final String userId) throws BankingException { return binder.getBankAccessEndpoint(userId).getBankAccesses(); } @Autowired BankingApiFacade(final BankingApiBinder binder); protected BankingApiFacade(); List<BankAccessBankingModel> ge...
### Question: BankingApiFacade { public List<BankAccountBankingModel> getBankAccounts(final String userId, final String bankAccessId) throws BankingException { return binder.getBankAccountEndpoint(userId).getBankAccounts(bankAccessId); } @Autowired BankingApiFacade(final BankingApiBinder binder); protected BankingApi...
### Question: BankingApiFacade { public List<BookingModel> syncBankAccount(final String userId, final String bankAccessId, final String bankAccountId, final String pin) throws BankingException { return binder.getBankAccountEndpoint(userId).syncBankAccount(bankAccessId, bankAccountId, pin); } @Autowired BankingApiFacad...
### Question: AbstractDataManager extends Observable implements DataManager<T> { @Override public SyncStatus getSyncStatus() { return syncStatus; } AbstractDataManager(DataProvider<T> dataProvider); @Override void sync(); @Override SyncStatus getSyncStatus(); @Override List<T> getAll(); @Override void add(final T eleme...
### Question: DummyBankAccountEndpoint implements BankAccountEndpoint { @Override public List<BookingModel> syncBankAccount(String bankAccessId, String bankAccountId, String pin) throws BankingException { if (!bookingModelMap.containsKey(bankAccountId)) { generateDummyBookingModels(bankAccountId); updateAccountBalance(...
### Question: BankingApiBinder { BankAccountEndpoint getBankAccountEndpoint(final String userId) { return isTestUser(userId) ? dummyBankAccountEndpoint : httpBankAccountEndpoint; } @Autowired BankingApiBinder(final BankingApiConfiguration bankingApiConfiguration, @Qualifier("default") final...
### Question: BankingApiBinder { BankAccessEndpoint getBankAccessEndpoint(final String userId) { return isTestUser(userId) ? dummyBankAccessEndpoint : httpBankAccessEndpoint; } @Autowired BankingApiBinder(final BankingApiConfiguration bankingApiConfiguration, @Qualifier("default") final Ban...
### Question: DummyBankAccessEndpoint implements BankAccessEndpoint { @Override public BankAccessBankingModel addBankAccess(BankAccessBankingModel bankAccess) throws BankingException { BankAccessBankingModel bankAccessBankingModel = new BankAccessBankingModel(); bankAccessBankingModel.setId("TestID" + number + "_" + Sy...
### Question: DummyBankAccessEndpoint implements BankAccessEndpoint { public boolean existsBankAccess(String bankAccessId) { return bankAccessEndpointRepository.exists(bankAccessId); } DummyBankAccessEndpoint(DummyBankAccessEndpointRepository bankAccessEndpointRepository); DummyBankAccessEndpoint(); @Override List<Ban...
### Question: DummyBankAccessEndpoint implements BankAccessEndpoint { @Override public List<BankAccessBankingModel> getBankAccesses() throws BankingException { List<DummyBankAccessBankingModelEntity> dummyBankAccessBankingModelEntities = bankAccessEndpointRepository.findAll(); List<BankAccessBankingModel> bankAccessBan...
### Question: AbstractDataManager extends Observable implements DataManager<T> { @Override public void add(final T element, final ServerCallStatusHandler handler) { logger().info("Adding element: " + element); Consumer<StringApiModel> onNext = new Consumer<StringApiModel>() { @Override public void accept(@NonNull final...
### Question: AuthenticationController { public String register(User user) throws VirtualLedgerAuthenticationException, UserAlreadyExistsException { if (user == null || user.getEmail() == null || user.getFirstName() == null || user.getLastName() == null) { throw new VirtualLedgerAuthenticationException( "Please check y...
### Question: StringApiModelFactory { public StringApiModel createStringApiModel(String string) { StringApiModel stringApiModel = new StringApiModel(); stringApiModel.setData(string); return stringApiModel; } StringApiModel createStringApiModel(String string); }### Answer: @Test public void createSuccessful() { Strin...
### Question: AbstractDataManager extends Observable implements DataManager<T> { @Override public List<T> getAll() throws SyncFailedException { if (syncFailedException != null) throw syncFailedException; if (syncStatus != SYNCED) throw new IllegalStateException("Sync not completed"); logger().info("Number items synct: ...
### Question: BankAccessFactory { public BankAccess createBankAccess(BankAccessBankingModel bankingModel) { BankAccess bankAccess = new BankAccess(bankingModel.getId(), bankingModel.getBankName(), bankingModel.getBankCode(), bankingModel.getBankLogin()); return bankAccess; } BankAccess createBankAccess(BankAccessBanki...
### Question: BankAccessFactory { public List<BankAccess> createBankAccesses(List<BankAccessBankingModel> bankingModelList) { List<BankAccess> bankAccessesResult = new ArrayList<BankAccess>(); for (BankAccessBankingModel bankingModel : bankingModelList) { bankAccessesResult.add(this.createBankAccess(bankingModel)); } r...
### Question: SavingsAccountIntoEntityTransformer { public User transformContactIntoEntity(Contact contact) { return new User(contact.getEmail(), contact.getFirstName(), contact.getLastName()); } SavingsAccountEntity transformSavingAccountIntoEntity(SavingsAccount savingsAccount, User currentUser); User transformConta...
### Question: SavingsAccountIntoEntityTransformer { public List<BankAccountIdentifierEntity> transformBankAccountIdentifierIntoEntity(List<BankAccountIdentifier> assignedBankAccounts) { List<BankAccountIdentifierEntity> bankAccountIdentifierEntities = new ArrayList<>(); if (assignedBankAccounts == null) { return bankAc...
### Question: BankAccessBankingModelFactory { public BankAccessBankingModel createBankAccessBankingModel(String userId, BankAccessCredential bankAccessCredential) { BankAccessBankingModel bankAccessBankingModel = new BankAccessBankingModel(); bankAccessBankingModel.setUserId(userId); bankAccessBankingModel.setBankCode(...
### Question: BankAccountFactory { public BankAccount createBankAccount(BankAccountBankingModel bankingModel) { double balance = 0; if (bankingModel.getBankAccountBalance() != null) { balance = bankingModel.getBankAccountBalance().getReadyHbciBalance(); } BankAccount bankAccount = new BankAccount(bankingModel.getId(), ...
### Question: BankAccountFactory { public List<BankAccount> createBankAccounts(List<BankAccountBankingModel> bankingModelList) { List<BankAccount> bankAccountsResult = new ArrayList<BankAccount>(); for (BankAccountBankingModel bankingModel : bankingModelList) { bankAccountsResult.add(this.createBankAccount(bankingModel...
### Question: AuthMigrator { public boolean hasLegacyAuth() { return mStorageHelpers.hasDigitsSession(); } @VisibleForTesting(otherwise = PRIVATE) AuthMigrator(@NonNull FirebaseApp app, @NonNull StorageHelpers storageHelper, @NonNull FirebaseAuth firebaseAuth); static AuthMigrator getInstance(Firebase...
### Question: AuthMigrator { public void clearLegacyAuth() { mStorageHelpers.clearDigitsSession(); } @VisibleForTesting(otherwise = PRIVATE) AuthMigrator(@NonNull FirebaseApp app, @NonNull StorageHelpers storageHelper, @NonNull FirebaseAuth firebaseAuth); static AuthMigrator getInstance(FirebaseApp ap...
### Question: RedeemableDigitsSessionBuilder { @NonNull static RedeemableDigitsSessionBuilder fromSessionJson(@NonNull String json) throws JSONException { RedeemableDigitsSessionBuilder builder = new RedeemableDigitsSessionBuilder(); JSONObject jsonObject = new JSONObject(json); JSONObject emailJsonObject = safeGetJson...
### Question: StfCommander { private static JCommander createCommander(CommandContainer commandContainer, String[] args) { JCommander.Builder builder = JCommander.newBuilder(); for (String operation : commandContainer.getAllCommands()) { CommandContainer.Command command = commandContainer.getCommand(operation); builder...
### Question: FileIOUtils { public static void createDeepHardlink(File sourceDir, File destDir) throws IOException { if (!sourceDir.exists()) { throw new IOException("Source directory " + sourceDir.getPath() + " doesn't exist"); } else if (!destDir.exists()) { throw new IOException("Destination directory " + destDir.ge...
### Question: PatternLayoutEscaped extends PatternLayout { @Override public String format(final LoggingEvent event) { if (event.getMessage() instanceof String) { return super.format(appendStackTraceToEvent(event)); } return super.format(event); } PatternLayoutEscaped(String s); PatternLayoutEscaped(); @Override String...
### Question: ExternalLinkUtils { public static String getExternalAnalyzerOnReq(Props azkProps, HttpServletRequest req) { if (!azkProps.containsKey(ServerProperties.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPIC)) { return ""; } String topic = azkProps.getString(ServerProperties.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPIC); return ...
### Question: ExternalLinkUtils { public static String getExternalLogViewer(Props azkProps, String jobId, Props jobProps) { if (!azkProps.containsKey(ServerProperties.AZKABAN_SERVER_EXTERNAL_LOGVIEWER_TOPIC)) { return ""; } String topic = azkProps.getString(ServerProperties.AZKABAN_SERVER_EXTERNAL_LOGVIEWER_TOPIC); ret...
### Question: ExternalLinkUtils { static String encodeToUTF8(String url) { try { return URLEncoder.encode(url, "UTF-8").replaceAll("\\+", "%20"); } catch (UnsupportedEncodingException e) { logger.error("Specified encoding is not supported", e); } return ""; } static String getExternalAnalyzerOnReq(Props azkProps, Http...
### Question: ExternalLinkUtils { static String getURLForTopic(String topic, Props azkProps) { return azkProps.getString(ServerProperties.AZKABAN_SERVER_EXTERNAL_TOPIC_URL.replace("${topic}", topic), ""); } static String getExternalAnalyzerOnReq(Props azkProps, HttpServletRequest req); static String getExternalLogView...
### Question: Emailer extends AbstractMailer implements Alerter { public void sendErrorEmail(ExecutableFlow flow, String... extraReasons) { EmailMessage message = new EmailMessage(mailHost, mailPort, mailUser, mailPassword); message.setFromAddress(mailSender); message.setTLS(tls); message.setAuth(super.hasMailAuth()); ...
### Question: RestfulApiClient { public T httpGet(URI uri, List<NameValuePair> headerEntries) throws IOException{ if (null == uri){ logger.error(" unable to perform httpGet as the passed uri is null"); return null; } HttpGet get = new HttpGet(uri); return this.sendAndReturn((HttpGet)completeRequest(get, headerEntries))...
### Question: RestfulApiClient { public T httpPost(URI uri, List<NameValuePair> headerEntries, String postingBody) throws UnsupportedEncodingException, IOException{ if (null == uri){ logger.error(" unable to perform httpPost as the passed uri is null."); return null; } HttpPost post = new HttpPost(uri); return this.sen...
### Question: RestfulApiClient { public T httpPut(URI uri, List<NameValuePair> headerEntries, String postingBody) throws UnsupportedEncodingException, IOException{ if (null == uri){ logger.error(" unable to perform httpPut as the passed url is null or empty."); return null; } HttpPut put = new HttpPut(uri); return this...
### Question: RestfulApiClient { public T httpDelete(URI uri, List<NameValuePair> headerEntries) throws IOException{ if (null == uri){ logger.error(" unable to perform httpDelete as the passed uri is null."); return null; } HttpDelete delete = new HttpDelete(uri); return this.sendAndReturn((HttpDelete)completeRequest(d...
### Question: AbstractMailer { protected EmailMessage createEmailMessage(String subject, String mimetype, Collection<String> emailList) { EmailMessage message = new EmailMessage(mailHost, mailPort, mailUser, mailPassword); message.setFromAddress(mailSender); message.addAllToAddress(emailList); message.setMimeType(mimet...
### Question: HttpRequestUtils { public static boolean validateIntegerParam(Map<String, String> params, String paramName) throws ExecutorManagerException { if (params != null && params.containsKey(paramName) && !StringUtils.isNumeric(params.get(paramName))) { throw new ExecutorManagerException(paramName + " should be a...
### Question: HttpRequestUtils { public static boolean hasPermission(UserManager userManager, User user, Permission.Type type) { for (String roleName : user.getRoles()) { Role role = userManager.getRole(roleName); if (role.getPermission().isPermissionSet(type) || role.getPermission().isPermissionSet(Permission.Type.ADM...
### Question: ValidationReport { public void addWarnLevelInfoMsg(String msg) { if (msg != null) { _infoMsgs.add("WARN" + msg); } } ValidationReport(); void addWarnLevelInfoMsg(String msg); void addErrorLevelInfoMsg(String msg); void addWarningMsgs(Set<String> msgs); void addErrorMsgs(Set<String> msgs); ValidationStatus...
### Question: ValidationReport { public void addErrorLevelInfoMsg(String msg) { if (msg != null) { _infoMsgs.add("ERROR" + msg); } } ValidationReport(); void addWarnLevelInfoMsg(String msg); void addErrorLevelInfoMsg(String msg); void addWarningMsgs(Set<String> msgs); void addErrorMsgs(Set<String> msgs); ValidationStat...
### Question: XmlValidatorManager implements ValidatorManager { @Override public List<String> getValidatorsInfo() { List<String> info = new ArrayList<String>(); for (String key : validators.keySet()) { info.add(key); } return info; } XmlValidatorManager(Props props); @Override void loadValidators(Props props, Logger lo...
### Question: PythonJob extends LongArgJob { public PythonJob(String jobid, Props sysProps, Props jobProps, Logger log) { super(jobid, new String[] { jobProps.getString(PYTHON_BINARY_KEY, "python"), jobProps.getString(SCRIPT_KEY) }, sysProps, jobProps, log, ImmutableSet.of(PYTHON_BINARY_KEY, SCRIPT_KEY, JOB_TYPE)); } P...
### Question: LoginAbstractAzkabanServlet extends AbstractAzkabanServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Session session = getSessionFromRequest(req); logRequest(req, session); if (hasParam(req, "logout")) { resp.sendRedirect(...
### Question: Permission { public void addPermissionsByName(String... list) { for (String perm : list) { Type type = Type.valueOf(perm); if (type != null) { addPermission(type); } ; } } Permission(); Permission(int flags); Permission(Type... list); void addPermissions(Permission perm); void setPermission(Type type, b...
### Question: QueuedExecutions { public void enqueue(ExecutableFlow exflow, ExecutionReference ref) throws ExecutorManagerException { if (hasExecution(exflow.getExecutionId())) { String errMsg = "Flow already in queue " + exflow.getExecutionId(); throw new ExecutorManagerException(errMsg); } Pair<ExecutionReference, Ex...
### Question: QueuedExecutions { public void enqueueAll( Collection<Pair<ExecutionReference, ExecutableFlow>> collection) throws ExecutorManagerException { for (Pair<ExecutionReference, ExecutableFlow> pair : collection) { enqueue(pair.getSecond(), pair.getFirst()); } } QueuedExecutions(long capacity); Pair<ExecutionRe...
### Question: QueuedExecutions { public long size() { return queuedFlowList.size(); } QueuedExecutions(long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(int executionId); void enqueue(ExecutableFlow exflow, ExecutionReference ref); void enqueueAll( Collection<Pair<ExecutionReference...
### Question: QueuedExecutions { public void dequeue(int executionId) { if (queuedFlowMap.containsKey(executionId)) { queuedFlowList.remove(queuedFlowMap.get(executionId)); queuedFlowMap.remove(executionId); } } QueuedExecutions(long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(int exec...
### Question: QueuedExecutions { public void clear() { for (Pair<ExecutionReference, ExecutableFlow> pair : queuedFlowMap.values()) { dequeue(pair.getFirst().getExecId()); } } QueuedExecutions(long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(int executionId); void enqueue(ExecutableFlo...
### Question: QueuedExecutions { public boolean isEmpty() { return queuedFlowList.isEmpty() && queuedFlowMap.isEmpty(); } QueuedExecutions(long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(int executionId); void enqueue(ExecutableFlow exflow, ExecutionReference ref); void enqueueAll( ...
### Question: QueuedExecutions { public Pair<ExecutionReference, ExecutableFlow> fetchHead() throws InterruptedException { Pair<ExecutionReference, ExecutableFlow> pair = queuedFlowList.take(); if (pair != null && pair.getFirst() != null) { queuedFlowMap.remove(pair.getFirst().getExecId()); } return pair; } QueuedExecu...
### Question: QueuedExecutions { public boolean isFull() { return size() >= capacity; } QueuedExecutions(long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(int executionId); void enqueue(ExecutableFlow exflow, ExecutionReference ref); void enqueueAll( Collection<Pair<ExecutionReferen...
### Question: QueuedExecutions { public boolean hasExecution(int executionId) { return queuedFlowMap.containsKey(executionId); } QueuedExecutions(long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(int executionId); void enqueue(ExecutableFlow exflow, ExecutionReference ref); void enqueue...
### Question: QueuedExecutions { public ExecutableFlow getFlow(int executionId) { if (hasExecution(executionId)) { return queuedFlowMap.get(executionId).getSecond(); } return null; } QueuedExecutions(long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(int executionId); void enqueue(Execut...