This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// here is the beginning of a typical test | |
@Test | |
public void should_list_the_total_number_of_threads() throws Exception { | |
User buyer = userRepository.save(user(1L, 0L, BUYER, folder(INBOX), folder(SENT), folder(TRASH), folder(SPAM), | |
folder(UNWANTED))); | |
User supplier = userRepository.save(user(2L, 20L, SUPPLIER, folder(INBOX), folder(SENT), folder(TRASH), | |
folder(SPAM), folder(UNWANTED))); | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConnectorExecutionCleanerTest { | |
private static final Connector CONNECTOR = new Connector("type", "name"); | |
private LocalWorkStore mockLocalWorkStore = mock(LocalWorkStore.class); | |
private LocalDataStore mockLocalDataStore = mock(LocalDataStore.class); | |
private Statistics mockStatistics = mock(Statistics.class); | |
private SystemProcessStatus mockSystemProcessStatus = mock(SystemProcessStatus.class); | |
private ConnectorExecutionCleaner cleaner = new ConnectorExecutionCleaner(mockLocalWorkStore, mockLocalDataStore, mockStatistics, mockSystemProcessStatus); | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void can_find_simple_hashtags() { | |
assertThat(parser.hashTags("#hashtag")).containsOnly("#hashtag"); | |
assertThat(parser.hashTags("#HASHTAG")).containsOnly("#HASHTAG"); | |
assertThat(parser.hashTags("#123hashtag")).containsOnly("#123hashtag"); | |
assertThat(parser.hashTags("#hash123tag")).containsOnly("#hash123tag"); | |
assertThat(parser.hashTags("#hashtag123")).containsOnly("#hashtag123"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.polyspot.connector.filesystem; | |
import java.util.List; | |
import org.apache.commons.vfs2.FileObject; | |
import org.apache.commons.vfs2.FileSystemManager; | |
import com.google.common.collect.Lists; | |
import com.polyspot.connector.framework.Connector; | |
import com.polyspot.connector.framework.ConnectorConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SleepSort { | |
private static Thread f(final int value) { | |
return new Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
Thread.sleep(value); | |
} catch (InterruptedException e) { | |
} | |
System.out.println(value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleWithExpliciteNamingTest { | |
private static final DateTime JANUARY_2 = utc(2000, 1, 2); | |
private static final DateTime JANUARY_3 = utc(2000, 1, 3); | |
private static final DateTime JANUARY_4 = utc(2000, 1, 4); | |
@Test | |
public void canGetRatioComparedToThePastNthDay() { | |
assertThat(evaluator.evaluateVariationsWithPastNthDay(dailyPerformances(JANUARY_4, 10000.0, 0.0, JANUARY_3, 10000.0, 0.0, JANUARY_2, 1000.0, 0.0), 2, null).getValue()).isEqualTo(9.0); | |
assertThat(evaluator.evaluateVariationsWithPastNthDay(dailyPerformances(JANUARY_3, 10000.0, 0.0, JANUARY_2, 1000.0, 0.0), 1, null).getValue()).isEqualTo(9.0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Our original test actually looks a bit better than this (more | |
* factorization, etc.), but I wanted to make a direct comparison with the | |
* new test. | |
*/ | |
@Test | |
public void canLoadChartsForDefaultSymbolAndCurrencyAndBarType_WITHOUT_NARRATIVE() throws IOException { | |
putInBacktestStore(getBackTestStore(), "1000", bars(Daily, CAC_BAR_CONTENT), bars(Hourly, FTSE_BAR_CONTENT)); | |
logInThenBeginAt(QUANT, QUANT_PASSWORD, "/users/backtestResults.html?backTestId=1000"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// our existing test | |
@Test | |
public void shouldLinkToStrategySourceCodeWithLinkBackToPaperSelectedPage() throws IOException { | |
getBackTestStore().storeStrategy(QUANT, ENDED_SOLUTION_ID, ZipUtils.zip("import com.algodeal.marketrunner.strategies.*;\n @Instruments(futures=com.algodeal.marketData.instruments.Futures.CAC_40)\npublic class MyStrategy extends AbstractStrategy {}", "MyStrategy.java")); | |
beginAtAsQuant("/users/paperTradeSolution.do?solutionId=" + ENDED_SOLUTION_ID + "&paperTrading=true"); // clicks on link executing javascript | |
beginAtAsQuant("/users/backtestHistory.html"); | |
clickLinkWithText("Show only", 1); | |
assertThat(getSolutionHtml(ENDED_SOLUTION_ID)).contains("<a href=\"/users/editStrategy.html?solutionId=" + ENDED_SOLUTION_ID + "&backUrl=/users/backtestHistory.html%3Fpage=1%26filter=PAPER\">"); |