method2testcases
stringlengths
118
3.08k
### Question: AtomicFloat extends Number implements java.io.Serializable { public final float incrementAndGet() { return addAndGet(1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update...
### Question: AtomicFloat extends Number implements java.io.Serializable { public final float decrementAndGet() { return addAndGet(-1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float updat...
### Question: AtomicFloat extends Number implements java.io.Serializable { public final float getAndIncrement() { return getAndAdd(1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float update...
### Question: AtomicFloat extends Number implements java.io.Serializable { public final float getAndDecrement() { return getAndAdd(-1.0f); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expect, float updat...
### Question: AtomicFloat extends Number implements java.io.Serializable { public final float getAndSet(float value) { return f(_ai.getAndSet(i(value))); } AtomicFloat(); AtomicFloat(float value); final float get(); final void set(float value); final float getAndSet(float value); final boolean compareAndSet(float expe...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final double get() { return d(_al.get()); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, double update); f...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final void set(double value) { _al.set(l(value)); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, double up...
### Question: CleanFormatter extends Formatter { public static String prependToLines(String prepend, String lines) { if (lines == null) return null; if (prepend == null) return lines; StringBuilder result = new StringBuilder(); boolean hasFinalNL = lines.endsWith(NL); StringTokenizer divided = new StringTokenizer(lines...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final double addAndGet(double delta) { for (;;) { long lexpect = _al.get(); double expect = d(lexpect); double update = expect+delta; long lupdate = l(update); if (_al.compareAndSet(lexpect,lupdate)) return update; } } AtomicDouble(); A...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final boolean compareAndSet(double expect, double update) { return _al.compareAndSet(l(expect),l(update)); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double val...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final boolean weakCompareAndSet(double expect, double update) { return _al.weakCompareAndSet(l(expect),l(update)); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(do...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final double incrementAndGet() { return addAndGet(1.0); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, dou...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final double decrementAndGet() { return addAndGet(-1.0); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, do...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final double getAndIncrement() { return getAndAdd(1.0); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, dou...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final double getAndDecrement() { return getAndAdd(-1.0); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(double expect, do...
### Question: AtomicDouble extends Number implements java.io.Serializable { public final double getAndSet(double value) { return d(_al.getAndSet(l(value))); } AtomicDouble(); AtomicDouble(double value); final double get(); final void set(double value); final double getAndSet(double value); final boolean compareAndSet(...
### Question: RTree extends AbstractSet<Object> { public Iterator<Object> iterator() { return new RTreeIterator(); } RTree(int ndim, int nmin, int nmax); RTree(int ndim, int nmin, int nmax, Boxer boxer); int size(); void clear(); boolean isEmpty(); boolean add(Object object); int addPacked(Object[] objects); boolean r...
### Question: Almost implements Serializable, Comparator<Number> { public double reciprocal(final double value) { return divide(1.0, value, 0.0); } Almost(); Almost(final double epsilon, final double minValue); Almost(final double epsilon); Almost(int significantDigits); Almost(final boolean isDouble); double getEp...
### Question: Almost implements Serializable, Comparator<Number> { public boolean between(final double x, final double x1, final double x2) { return ((cmp(x, x1) * cmp(x, x2)) <= 0); } Almost(); Almost(final double epsilon, final double minValue); Almost(final double epsilon); Almost(int significantDigits); Almost(...
### Question: Almost implements Serializable, Comparator<Number> { @Override public int compare(final Number n1, final Number n2) { return cmp(n1.doubleValue(), n2.doubleValue()); } Almost(); Almost(final double epsilon, final double minValue); Almost(final double epsilon); Almost(int significantDigits); Almost(fin...
### Question: Almost implements Serializable, Comparator<Number> { public boolean zero(double r) { if (r < 0.0) { r = -r; } return (r < _minValue); } Almost(); Almost(final double epsilon, final double minValue); Almost(final double epsilon); Almost(int significantDigits); Almost(final boolean isDouble); double get...
### Question: Almost implements Serializable, Comparator<Number> { public double getEpsilon() { return _epsilon; } Almost(); Almost(final double epsilon, final double minValue); Almost(final double epsilon); Almost(int significantDigits); Almost(final boolean isDouble); double getEpsilon(); double getMinValue(); bo...
### Question: Almost implements Serializable, Comparator<Number> { public double getMinValue() { return _minValue; } Almost(); Almost(final double epsilon, final double minValue); Almost(final double epsilon); Almost(int significantDigits); Almost(final boolean isDouble); double getEpsilon(); double getMinValue(); ...
### Question: ArgsParser { public static boolean toBoolean(String s) throws OptionException { s = s.toLowerCase(); if (s.equals("true")) return true; if (s.equals("false")) return false; throw new OptionException("the value "+s+" is not a valid boolean"); } ArgsParser(String[] args, String shortOpts); ArgsParser(Strin...
### Question: Almost implements Serializable, Comparator<Number> { public boolean equal(final double r1, final double r2) { return (cmp(r1, r2) == 0); } Almost(); Almost(final double epsilon, final double minValue); Almost(final double epsilon); Almost(int significantDigits); Almost(final boolean isDouble); double ...
### Question: UnitSphereSampling { private static void testSymmetry(UnitSphereSampling uss) { int mi = uss.getMaxIndex(); for (int i=1,j=-i; i<=mi; ++i,j=-i) { float[] p = uss.getPoint(i); float[] q = uss.getPoint(j); assert p[0]==-q[0]; assert p[1]==-q[1]; assert p[2]==-q[2]; } int npoint = 10000; for (int ipoint=0; i...
### Question: UnitSphereSampling { private static void testTriangle(UnitSphereSampling uss) { int npoint = 1000000; for (int ipoint=0; ipoint<npoint; ++ipoint) { float[] p = randomPoint(); int i = uss.getIndex(p); int[] abc = uss.getTriangle(p); int ia = abc[0], ib = abc[1], ic = abc[2]; float[] q = uss.getPoint(i); fl...
### Question: ArgsParser { public static double toDouble(String s) throws OptionException { try { return Double.valueOf(s); } catch (NumberFormatException e) { throw new OptionException("the value "+s+" is not a valid double"); } } ArgsParser(String[] args, String shortOpts); ArgsParser(String[] args, String shortOpts...
### Question: ArgsParser { public static float toFloat(String s) throws OptionException { try { return Float.valueOf(s); } catch (NumberFormatException e) { throw new OptionException("the value "+s+" is not a valid float"); } } ArgsParser(String[] args, String shortOpts); ArgsParser(String[] args, String shortOpts, St...
### Question: ArgsParser { public static int toInt(String s) throws OptionException { try { return Integer.parseInt(s); } catch (NumberFormatException e) { throw new OptionException("the value "+s+" is not a valid int"); } } ArgsParser(String[] args, String shortOpts); ArgsParser(String[] args, String shortOpts, Strin...
### Question: ArgsParser { public static long toLong(String s) throws OptionException { try { return Long.parseLong(s); } catch (NumberFormatException e) { throw new OptionException("the value "+s+" is not a valid long"); } } ArgsParser(String[] args, String shortOpts); ArgsParser(String[] args, String shortOpts, Stri...
### Question: BrentZeroFinder { public double findZero(double a, double b, double tol) { double fa = _f.evaluate(a); double fb = _f.evaluate(b); return findZero(a,fa,b,fb,tol); } BrentZeroFinder(Function f); double f(double x); double findZero(double a, double b, double tol); double findZero( double a, double fa, d...
### Question: BoundingBoxTree { public Node getRoot() { return _root; } BoundingBoxTree(int minSize, float[] xyz); BoundingBoxTree(int minSize, float[] x, float[] y, float[] z); Node getRoot(); }### Answer: @Test public void testRandom() { int minSize = 10; int n = 10000; float[] x = randfloat(n); float[] y = randflo...
### Question: DMatrixChd { public double det() { return _det; } DMatrixChd(DMatrix a); boolean isPositiveDefinite(); DMatrix getL(); double det(); DMatrix solve(DMatrix b); }### Answer: @Test public void testSimple() { DMatrix a = new DMatrix(new double[][]{ {1.0, 1.0}, {1.0, 4.0}, }); test(a); DMatrixChd chd = new DM...
### Question: DMatrixLud { public double det() { Check.argument(_m==_n,"A is square"); return _det; } DMatrixLud(DMatrix a); boolean isSingular(); DMatrix getL(); DMatrix getU(); DMatrix getP(); int[] getPivotIndices(); double det(); DMatrix solve(DMatrix b); }### Answer: @Test public void testSimple() { DMatrix a = n...
### Question: DMatrixQrd { public boolean isFullRank() { for (int j=0; j<_n; ++j) { if (_qr[j+j*_m]==0.0) return false; } return true; } DMatrixQrd(DMatrix a); boolean isFullRank(); DMatrix getQ(); DMatrix getR(); DMatrix solve(DMatrix b); }### Answer: @Test public void testRankDeficient() { DMatrix a = new DMatrix(ne...
### Question: DMatrixSvd { public double cond() { return _s[0]/_s[_mn-1]; } DMatrixSvd(DMatrix a); DMatrix getU(); DMatrix getS(); double[] getSingularValues(); DMatrix getV(); DMatrix getVTranspose(); double norm2(); double cond(); int rank(); }### Answer: @Test public void testCond() { DMatrix a = new DMatrix(new do...
### Question: ArgsParser { public ArgsParser(String[] args, String shortOpts) throws OptionException { _args = args; _shortOpts = shortOpts; _longOpts = new String[0]; init(); } ArgsParser(String[] args, String shortOpts); ArgsParser(String[] args, String shortOpts, String[] longOpts); String[] getOptions(); String[] ...
### Question: DataSetParametersList { public static DataSetParametersList fromXML(String dataDefinition) throws SourceBeanException { return new DataSetParametersList(dataDefinition); } DataSetParametersList(); DataSetParametersList(String dataDefinition); void loadFromXML(String dataDefinition); String toXML(); Strin...
### Question: ParametersDecoder { public boolean isMultiValues(String value) { return value.trim().matches(multiValueRegex); } ParametersDecoder(); ParametersDecoder(String openBlockMarker, String closeBlockMarker); String getCloseBlockMarker(); void setCloseBlockMarker(String closeBlockMarker); String getOpenBlockMar...
### Question: SimpleRestClient { protected Response executeGetService(Map<String, Object> parameters, String serviceUrl, String userId) throws Exception { return executeService(parameters, serviceUrl, userId, RequestTypeEnum.GET, null, null); } SimpleRestClient(String hmacKey); SimpleRestClient(); boolean isAddServerU...
### Question: SimpleRestClient { protected Response executePostService(Map<String, Object> parameters, String serviceUrl, String userId, String mediaType, Object data) throws Exception { return executeService(parameters, serviceUrl, userId, RequestTypeEnum.POST, mediaType, data); } SimpleRestClient(String hmacKey); Si...
### Question: RealtimeEvaluationStrategy extends CachedEvaluationStrategy { @Override protected DatasetEvaluationStrategyType getEvaluationStrategy() { return DatasetEvaluationStrategyType.REALTIME; } RealtimeEvaluationStrategy(UserProfile userProfile, IDataSet dataSet, ICache cache); }### Answer: @Test public void s...
### Question: PersistedEvaluationStrategy extends AbstractJdbcEvaluationStrategy { @Override protected String getTableName() { return dataSet.getPersistTableName(); } PersistedEvaluationStrategy(IDataSet dataSet); }### Answer: @Test public void shouldUsePersistedTableName() { final String TABLE_NAME = "PersistedTable...
### Question: PersistedEvaluationStrategy extends AbstractJdbcEvaluationStrategy { @Override protected IDataSource getDataSource() { return dataSet.getDataSourceForWriting(); } PersistedEvaluationStrategy(IDataSet dataSet); }### Answer: @Test public void shouldUseDatasourceForWriting() { final String DATASOURCE_LABEL...
### Question: PersistedEvaluationStrategy extends AbstractJdbcEvaluationStrategy { @Override protected Date getDate() { Date toReturn = null; Trigger trigger = loadTrigger(); Date previousFireTime = null; if (trigger != null) { previousFireTime = trigger.getPreviousFireTime(); } if (previousFireTime != null) { toReturn...
### Question: CachedEvaluationStrategy extends AbstractEvaluationStrategy { protected DatasetEvaluationStrategyType getEvaluationStrategy() { return DatasetEvaluationStrategyType.CACHED; } CachedEvaluationStrategy(UserProfile userProfile, IDataSet dataSet, ICache cache); }### Answer: @Test public void shouldReturnCac...
### Question: LabeledEdge extends DefaultEdge { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; LabeledEdge other = (LabeledEdge) obj; if (label == null) { if (other.label != null) return false; } else if (!label....
### Question: EdgeGroup { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof EdgeGroup)) return false; EdgeGroup other = (EdgeGroup) obj; if (orderedEdgeNames == null) { if (other.orderedEdgeNames != null) return false; } else if (!orderedEdge...
### Question: EdgeGroup { public String getOrderedEdgeNames() { return orderedEdgeNames; } EdgeGroup(Set<LabeledEdge<String>> edges); Set<String> getEdgeNames(); String getOrderedEdgeNames(); Set<Tuple> getValues(); void addValues(Set<Tuple> values); void addValue(Tuple value); boolean isResolved(); void resolve(); voi...
### Question: DataSetParametersList { public void loadFromXML(String dataDefinition) throws SourceBeanException { logger.debug("IN"); dataDefinition.trim(); InputSource stream = new InputSource(new StringReader(dataDefinition)); SourceBean source = SourceBean.fromXMLStream(stream); if (!source.getName().equals("PARAMET...
### Question: ExceptionUtilities { public static String getStackTraceAsString( Exception aException ){ String vStackTrace = "\t" + aException.toString() + "\n"; for( StackTraceElement vElement : aException.getStackTrace() ){ vStackTrace += "\t\t" + vElement.toString() + "\n"; } return vStackTrace; } static String getS...
### Question: ToServerManagement extends Thread { public static ToServerManagement getInstance() { if( ToServerManagement.sINSTANCE == null){ ToServerManagement.sINSTANCE = new ToServerManagement(); } return ToServerManagement.sINSTANCE; } ToServerManagement(); static ToServerManagement getInstance(); void close(); voi...
### Question: ToServerManagement extends Thread { public void stopManagement(){ synchronized (this) { mManageMessagesToServer = false; } if( isAlive()){ resumeManagement(); while(isAlive()){ try { Thread.sleep( 10 ); } catch ( Exception vException ) { Core.getLogger().error( "Error stopping ToServerManagement.", vExcep...
### Question: ToServerManagement extends Thread { public boolean isSendingMessages(){ return isAlive() && (System.currentTimeMillis() - mLastSendMessage.get() ) < 100; } ToServerManagement(); static ToServerManagement getInstance(); void close(); void resumeManagement(); boolean isSuspended(); void suspendManagement();...
### Question: Movement implements Action { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Movement other = (Movement) obj; if (mLeftWheelVelocity != other.mLeftWheelVelocity) return false; if (mRightWheelVelocity...
### Question: FellowPlayer extends ReferencePoint { @Override void setPointName( ReferencePointName aPointName ) { super.setPointName( ReferencePointName.Player ); mId = IDCOUNTER++; } FellowPlayer(); FellowPlayer(int aId, String aNickname, Boolean aStatus, double aDistanceToPlayer, double aAngleToPlayer, double aOrie...
### Question: ReferencePoint { public void setXOfPoint( double aXValue ) { mX = aXValue; set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates ); ReferencePoint( Refere...
### Question: ReferencePoint { public void setYOfPoint( double aYValue ) { mY = aYValue; set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates ); ReferencePoint( Refere...
### Question: ReferencePoint { public ReferencePoint copy () { return new ReferencePoint( this ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates ); ReferencePoint( ReferencePoint aRef...
### Question: ReferencePoint { public ReferencePoint add( ReferencePoint aReferencePoint ) { mX += aReferencePoint.mX; mY += aReferencePoint.mY; return set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSe...
### Question: ReferencePoint { public ReferencePoint multiply( double scalar ) { mX *= scalar; mY *= scalar; return set( mX, mY, false ); } ReferencePoint( ); @Deprecated ReferencePoint( double aDistanceToPoint, double aAngleToPoint ); ReferencePoint( double aFirstValue, double aSecondValue, boolean aPolarcoordinates...
### Question: Kick implements Action { @Override public String getXMLString() { return "<command> <kick> <angle>" + mAngle + "</angle> <force>" + mForce + "</force> </kick> </command>"; } Kick( double aAngle, float aForce); @Override String getXMLString(); double getAngle(); float getForce(); }### Answer: @Test public...
### Question: Movement implements Action { @Override public String getXMLString() { return "<command> <wheel_velocities> <right>" + mRightWheelVelocity + "</right> <left>" + mLeftWheelVelocity + "</left> </wheel_velocities> </command>"; } Movement( int aRightWheelVelocity, int aLeftWheelVelocity ); int getmRightWheelVe...
### Question: ObjectFactory { public RawWorldData createRawWorldData() { return new RawWorldData(); } RawWorldData createRawWorldData(); }### Answer: @Test public void testCreateRawWorldData() { ObjectFactory objectFactory = new ObjectFactory(); assertThat(objectFactory.createRawWorldData()).isInstanceOf(RawWorldData...
### Question: InitialConnectionData implements Action { public InitialConnectionData( BotInformation aBot ){ mConnection.type = "Client"; mConnection.protocol_version = 1.0; mConnection.nickname = aBot.getBotname(); mConnection.rc_id = aBot.getRcId(); mConnection.vt_id = aBot.getVtId(); } InitialConnectionData( BotInfo...
### Question: InitialConnectionData implements Action { @Override public String getXMLString() { StringWriter vXMLDataStream = new StringWriter(); JAXB.marshal( mConnection, vXMLDataStream ); String vXMLDataString = vXMLDataStream.toString(); vXMLDataString = vXMLDataString.substring( vXMLDataString.indexOf('>') + 2 );...
### Question: NetworkCommunication { public void sendDatagramm( String aData ) throws IOException { mDataPaket.setData( aData.getBytes() ); mToServerSocket.send( mDataPaket ); } NetworkCommunication( InetAddress aServerAddress, int aServerPort ); NetworkCommunication( InetAddress aServerAddress, int aServerPort, int a...
### Question: Movement implements Action { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + mLeftWheelVelocity; result = prime * result + mRightWheelVelocity; return result; } Movement( int aRightWheelVelocity, int aLeftWheelVelocity ); int getmRightWheelVelocity(); int ...
### Question: Core { synchronized public BotInformation getBotinformation() { Core.getLogger().debug( "Retriving Botinformation: \n" + mBotinformation.toString() ); return mBotinformation; } Core(); Core( BotInformation aBotInformation ); static Core getInstance(); static synchronized Logger getLogger(); void close()...
### Question: Core { public static Core getInstance() { if( Core.sINSTANCE == null){ Core.getLogger().trace( "Creating Core-instance." ); Core.sINSTANCE = new Core(); } Core.getLogger().trace( "Retrieving Core-instance." ); return Core.sINSTANCE; } Core(); Core( BotInformation aBotInformation ); static Core getInstan...
### Question: Core { public static synchronized Logger getLogger(){ return sBOTCORELOGGER; } Core(); Core( BotInformation aBotInformation ); static Core getInstance(); static synchronized Logger getLogger(); void close(); void startBot( String[] aCommandline ); @SuppressWarnings("resource") boolean initializeAI(); vo...
### Question: FromServerManagement extends Thread { @Override public void start(){ startManagement(); } FromServerManagement(); static FromServerManagement getInstance(); void close(); void resumeManagement(); void suspendManagement(); boolean isSuspended(); @Override void start(); void startManagement(); void stopMana...
### Question: FromServerManagement extends Thread { public static FromServerManagement getInstance() { if( FromServerManagement.sINSTANCE == null){ FromServerManagement.sINSTANCE = new FromServerManagement(); } return FromServerManagement.sINSTANCE; } FromServerManagement(); static FromServerManagement getInstance(); v...
### Question: FromServerManagement extends Thread { public void stopManagement(){ synchronized (this) { mManageMessagesFromServer = false; } if( isAlive()){ mSuspended = false; while(isAlive()){ try { Thread.sleep( 10 ); } catch ( Exception vException ) { Core.getLogger().error( "Error stopping FromServerManagement.", ...
### Question: FromServerManagement extends Thread { public boolean isReceivingMessages(){ return isAlive() && (System.currentTimeMillis() - mLastReceivedMessage.get()) < 100; } FromServerManagement(); static FromServerManagement getInstance(); void close(); void resumeManagement(); void suspendManagement(); boolean isS...
### Question: ReloadAiManagement extends Thread { @Override public void start(){ startManagement(); } ReloadAiManagement(); static ReloadAiManagement getInstance(); void close(); @Override void start(); void startManagement(); void stopManagement(); @Override void run(); }### Answer: @Test public void testStartWhileNo...
### Question: ReloadAiManagement extends Thread { public static ReloadAiManagement getInstance() { if( ReloadAiManagement.sINSTANCE == null){ ReloadAiManagement.sINSTANCE = new ReloadAiManagement(); } return ReloadAiManagement.sINSTANCE; } ReloadAiManagement(); static ReloadAiManagement getInstance(); void close(); @Ov...
### Question: ReloadAiManagement extends Thread { public void stopManagement(){ mAiActive = false; if( isAlive()){ Core.getLogger().info( "RestartAiServerManagement stopping." ); while(isAlive()){ try { Thread.sleep( 10 ); } catch ( Exception vException ) { Core.getLogger().error( "Error stopping RestartAiServerManagem...
### Question: ReloadAiManagement extends Thread { @Override public void run(){ while( mAiActive ){ try { if(Core.getInstance().getAI() != null && Core.getInstance().getAI().wantRestart()){ Core.getInstance().initializeAI(); Core.getInstance().resumeAI(); Thread.sleep( 500 ); } Thread.sleep( 50 ); } catch ( Exception vE...
### Question: ToServerManagement extends Thread { @Override public void start(){ this.startManagement(); } ToServerManagement(); static ToServerManagement getInstance(); void close(); void resumeManagement(); boolean isSuspended(); void suspendManagement(); @Override void start(); void startManagement(); void stopManag...
### Question: ProfileInfoResource { @GetMapping("/profile-info") public ProfileInfoVM getActiveProfiles() { String[] activeProfiles = DefaultProfileUtil.getActiveProfiles(env); return new ProfileInfoVM(activeProfiles, getRibbonEnv(activeProfiles)); } ProfileInfoResource(Environment env, JHipsterProperties jHipsterPrope...
### Question: TokenProvider { public boolean validateToken(String authToken) { try { Jwts.parser().setSigningKey(secretKey).parseClaimsJws(authToken); return true; } catch (SignatureException e) { log.info("Invalid JWT signature."); log.trace("Invalid JWT signature trace: {}", e); } catch (MalformedJwtException e) { lo...
### Question: LogsResource { @GetMapping("/logs") @Timed public List<LoggerVM> getList() { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); return context.getLoggerList() .stream() .map(LoggerVM::new) .collect(Collectors.toList()); } @GetMapping("/logs") @Timed List<LoggerVM> getList(); @PutM...
### Question: LogsResource { @PutMapping("/logs") @ResponseStatus(HttpStatus.NO_CONTENT) @Timed public void changeLevel(@RequestBody LoggerVM jsonLogger) { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel())); }...
### Question: SshResource { @GetMapping(value = "/ssh/public_key", produces = MediaType.TEXT_PLAIN_VALUE) @Timed public ResponseEntity<String> eureka() { try { String publicKey = getPublicKey(); if(publicKey != null) return new ResponseEntity<>(publicKey, HttpStatus.OK); } catch (IOException e) { log.warn("SSH public k...
### Question: ExceptionTranslator { @ExceptionHandler(CustomParameterizedException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public ParameterizedErrorVM processParameterizedValidationError(CustomParameterizedException ex) { return ex.getErrorVM(); } @ExceptionHandler(MethodArgumentNotValidException....
### Question: ExceptionTranslator { @ExceptionHandler(AccessDeniedException.class) @ResponseStatus(HttpStatus.FORBIDDEN) @ResponseBody public ErrorVM processAccessDeniedException(AccessDeniedException e) { return new ErrorVM(ErrorConstants.ERR_ACCESS_DENIED, e.getMessage()); } @ExceptionHandler(MethodArgumentNotValidE...
### Question: ExceptionTranslator { @ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTE...
### Question: ExceptionTranslator { @ExceptionHandler(Exception.class) public ResponseEntity<ErrorVM> processRuntimeException(Exception ex) { BodyBuilder builder; ErrorVM errorVM; ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class); if (responseStatus != null) { builder =...
### Question: CustomParameterizedException extends RuntimeException { public ParameterizedErrorVM getErrorVM() { return new ParameterizedErrorVM(message, paramMap); } CustomParameterizedException(String message, String... params); CustomParameterizedException(String message, Map<String, String> paramMap); Parameterize...
### Question: FieldErrorVM implements Serializable { public String getObjectName() { return objectName; } FieldErrorVM(String dto, String field, String message); String getObjectName(); String getField(); String getMessage(); }### Answer: @Test public void getObjectNameTest() throws Exception { FieldErrorVM vm = new F...
### Question: FieldErrorVM implements Serializable { public String getField() { return field; } FieldErrorVM(String dto, String field, String message); String getObjectName(); String getField(); String getMessage(); }### Answer: @Test public void getFieldTest() throws Exception { FieldErrorVM vm = new FieldErrorVM(nul...
### Question: FieldErrorVM implements Serializable { public String getMessage() { return message; } FieldErrorVM(String dto, String field, String message); String getObjectName(); String getField(); String getMessage(); }### Answer: @Test public void getMessageTest() throws Exception { FieldErrorVM vm = new FieldError...
### Question: ErrorVM implements Serializable { public void add(String objectName, String field, String message) { if (fieldErrors == null) { fieldErrors = new ArrayList<>(); } fieldErrors.add(new FieldErrorVM(objectName, field, message)); } ErrorVM(String message); ErrorVM(String message, String description); ErrorV...
### Question: ErrorVM implements Serializable { public String getMessage() { return message; } ErrorVM(String message); ErrorVM(String message, String description); ErrorVM(String message, String description, List<FieldErrorVM> fieldErrors); void add(String objectName, String field, String message); String getMessage...
### Question: ErrorVM implements Serializable { public String getDescription() { return description; } ErrorVM(String message); ErrorVM(String message, String description); ErrorVM(String message, String description, List<FieldErrorVM> fieldErrors); void add(String objectName, String field, String message); String ge...
### Question: ParameterizedErrorVM implements Serializable { public String getMessage() { return message; } ParameterizedErrorVM(String message, Map<String, String> paramMap); String getMessage(); Map<String, String> getParams(); }### Answer: @Test public void getMessageTest() { ParameterizedErrorVM vm = new Parameter...
### Question: ParameterizedErrorVM implements Serializable { public Map<String, String> getParams() { return paramMap; } ParameterizedErrorVM(String message, Map<String, String> paramMap); String getMessage(); Map<String, String> getParams(); }### Answer: @Test public void getParamsTest() { ParameterizedErrorVM vm = n...
### Question: EurekaVM { public List<Map<String, Object>> getApplications() { return applications; } List<Map<String, Object>> getApplications(); void setApplications(List<Map<String, Object>> applications); Map<String, Object> getStatus(); void setStatus(Map<String, Object> status); }### Answer: @Test public void ge...