target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testEvaluateAlgorithmsCommandWithSystemConfigWithUnknownEvaluationIdentifier() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { String inCorrectresult = String.format( TestUtils.getStringByReflection(EvaluateAlgorithmsCommand.class, REFLECTION_EVALUATI...
@Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); logger.error(failureReason, commandCannotBeExe...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
@Test @Override public void testCorrectParameters() throws JsonParsingFailedException { List<JsonObject> listOfJsonObjects = getCorrectParameters(); for (int i = 0; i < listOfJsonObjects.size(); i++) { IDistribution<SPACE> distribution = getDistribution(); try { distribution.setParameters(listOfJsonObjects.get(i)); } c...
@Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getDistributionConfiguration().overrideConfiguration(jsonObject); }
ADistribution implements IDistribution<SPACE> { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getDistributionConfiguration().overrideConfiguration(jsonObject); } }
ADistribution implements IDistribution<SPACE> { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getDistributionConfiguration().overrideConfiguration(jsonObject); } ADistribution(); }
ADistribution implements IDistribution<SPACE> { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getDistributionConfiguration().overrideConfiguration(jsonObject); } ADistribution(); @Override List<SPACE> generateSamples(int numberOfSamples); abstract CONFIG createDe...
ADistribution implements IDistribution<SPACE> { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getDistributionConfiguration().overrideConfiguration(jsonObject); } ADistribution(); @Override List<SPACE> generateSamples(int numberOfSamples); abstract CONFIG createDe...
@Test public void testEvaluateAlgorithmsCommandWithSystemConfigHaveNoEvaluation() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { String inCorrectresult = String.format( TestUtils.getStringByReflection(EvaluateAlgorithmsCommand.class, REFLECTION_EVALUATION_FOR_LEARNING...
@Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); logger.error(failureReason, commandCannotBeExe...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
@Test public void testEvaluateAlgorithmsCommandWithSystemConfigWithNoAlgorithmsSet() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { runSystemConfigCommandWithFileWithoutLoadingAlgorithms(getTestRessourcePathFor(SYSTEM_CONFIG_JSON_FILE)); currentCommand = new String[] ...
@Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); logger.error(failureReason, commandCannotBeExe...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
@Test public void testEvaluateAlgorithmsCommandWithSystemConfigWithNoSetupForEvaluation() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { runSystemConfigCommandWithFileWithoutTrainingModels(getTestRessourcePathFor(SYSTEM_CONFIG_COMPLETE_WITH_SETUP_PROBLEM_IN_EVALUATION...
@Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); logger.error(failureReason, commandCannotBeExe...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
EvaluateAlgorithmsCommand extends ACommand { @Override public boolean canBeExecuted() { try { checkInitialParametersForCommandExecution(); } catch (CommandCannotBeExecutedException commandCannotBeExecuted) { failureReason = String.format(COMMAND_CANNOT_BE_EXECUTED_ERROR_MESSAGE, commandCannotBeExecuted.getMessage()); l...
@Test public void testRunCompleteToolChainCommand() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { String command[] = { ECommand.RUN_COMPLETE_TOOLCHAIN.getCommandIdentifier(), PARAMETER_CONFIG + getTestRessourcePathFor(CORRECT_SYSTEM_CONFIG_JSON) }; TestUtils.simulate...
public RunCompleteToolChainCommand(RunCompleteToolChainCommandConfiguration commandConfiguration) { super(ECommand.RUN_COMPLETE_TOOLCHAIN.getCommandIdentifier()); this.commandConfiguration = commandConfiguration; toolChainCommands = new ArrayList<>(); commandExecutionSuccessPairs = new ArrayList<>(); inputControl = Inp...
RunCompleteToolChainCommand extends ACommand { public RunCompleteToolChainCommand(RunCompleteToolChainCommandConfiguration commandConfiguration) { super(ECommand.RUN_COMPLETE_TOOLCHAIN.getCommandIdentifier()); this.commandConfiguration = commandConfiguration; toolChainCommands = new ArrayList<>(); commandExecutionSucce...
RunCompleteToolChainCommand extends ACommand { public RunCompleteToolChainCommand(RunCompleteToolChainCommandConfiguration commandConfiguration) { super(ECommand.RUN_COMPLETE_TOOLCHAIN.getCommandIdentifier()); this.commandConfiguration = commandConfiguration; toolChainCommands = new ArrayList<>(); commandExecutionSucce...
RunCompleteToolChainCommand extends ACommand { public RunCompleteToolChainCommand(RunCompleteToolChainCommandConfiguration commandConfiguration) { super(ECommand.RUN_COMPLETE_TOOLCHAIN.getCommandIdentifier()); this.commandConfiguration = commandConfiguration; toolChainCommands = new ArrayList<>(); commandExecutionSucce...
RunCompleteToolChainCommand extends ACommand { public RunCompleteToolChainCommand(RunCompleteToolChainCommandConfiguration commandConfiguration) { super(ECommand.RUN_COMPLETE_TOOLCHAIN.getCommandIdentifier()); this.commandConfiguration = commandConfiguration; toolChainCommands = new ArrayList<>(); commandExecutionSucce...
@Test(expected = UnsupportedOperationException.class) public void testUpdateFailureWithWrongObservable() { inputControl.update(new DetermineApplicableAlgorithmsCommandHandler(), StringUtils.EMPTY_STRING); }
@Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, arg)); } }
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
@Test(expected = UnsupportedOperationException.class) public void testUpdateFailureWithWrongArgument() { inputControl.update(CommandLineParserView.getCommandLineParserView(), new Exception()); }
@Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, arg)); } }
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
InputControl implements Observer { @Override public void update(Observable o, Object arg) { if (o instanceof CommandLineParserView && arg instanceof String[]) { String[] userInput = (String[]) arg; handleUserInput(userInput); } else { throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_UPDATE, o, ar...
@Test public void testParseInvalidDataset() { List<DatasetFile> datasets = getInvalidDatasets(); for (int i = 0; i < datasets.size(); i++) { try { DatasetFile datasetFile = datasets.get(i); getDatasetParser().parse(datasetFile); fail(PARSING_FAILED_EXCEPTION_EXPECTED_BUT_NOT_FOUND); } catch (ParsingFailedException e) {...
@Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); }
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } }
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } }
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } @Override IDataset<?, ?, ?> parse(DatasetFile file); @Override IDataset<?, ?, ?> parsePartialOf(DatasetFile file, int amountOfInstances...
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } @Override IDataset<?, ?, ?> parse(DatasetFile file); @Override IDataset<?, ?, ?> parsePartialOf(DatasetFile file, int amountOfInstances...
@Test public void testParseValidDataset() throws ParsingFailedException { List<DatasetFile> datasets = getValidDatasets(); for (int i = 0; i < datasets.size(); i++) { DatasetFile datasetFile = datasets.get(i); IDatasetParser parser = getDatasetParser(); parser.parse(datasetFile); validateDataset(i, parser.getDataset())...
@Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); }
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } }
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } }
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } @Override IDataset<?, ?, ?> parse(DatasetFile file); @Override IDataset<?, ?, ?> parsePartialOf(DatasetFile file, int amountOfInstances...
ADatasetParser implements IDatasetParser { @Override public IDataset<?, ?, ?> parse(DatasetFile file) throws ParsingFailedException { return parsePartialOf(file, Integer.MAX_VALUE); } @Override IDataset<?, ?, ?> parse(DatasetFile file); @Override IDataset<?, ?, ?> parsePartialOf(DatasetFile file, int amountOfInstances...
@Override @Test public void testCorrectPredictions() { List<IDataset<double[], List<double[]>, IVector>> correctDatasetList = getCorrectDatasetList(); List<Pair<IDataset<double[], List<double[]>, IVector>, List<IVector>>> predictionDatasetList = getPredictionsForDatasetList(); Assert.assertEquals(ERROR_DIFFERENT_LIST_L...
@Override public CombinedRankingAndRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (CombinedRankingAndRegressionLearningModel) super.train(dataset); }
CombinedRankingAndRegressionLearningAlgorithm extends ALearningAlgorithm<CombinedRankingAndRegressionConfiguration> { @Override public CombinedRankingAndRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (CombinedRankingAndRegressionLearningModel) super.train(dataset); }...
CombinedRankingAndRegressionLearningAlgorithm extends ALearningAlgorithm<CombinedRankingAndRegressionConfiguration> { @Override public CombinedRankingAndRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (CombinedRankingAndRegressionLearningModel) super.train(dataset); }...
CombinedRankingAndRegressionLearningAlgorithm extends ALearningAlgorithm<CombinedRankingAndRegressionConfiguration> { @Override public CombinedRankingAndRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (CombinedRankingAndRegressionLearningModel) super.train(dataset); }...
CombinedRankingAndRegressionLearningAlgorithm extends ALearningAlgorithm<CombinedRankingAndRegressionConfiguration> { @Override public CombinedRankingAndRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (CombinedRankingAndRegressionLearningModel) super.train(dataset); }...
@Test @Ignore public void pairwiseRankingAlgorithmTestCorrectInput() throws ParsingFailedException, TrainModelsFailedException, PredictionFailedException, LossException { File file = new File(getTestRessourcePathFor(OBJECT_RANKING_DATASET_B)); PairwiseRankingLearningAlgorithm algortihm = new PairwiseRankingLearningAlgo...
@Override public PairwiseRankingLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (PairwiseRankingLearningModel) super.train(dataset); }
PairwiseRankingLearningAlgorithm extends AObjectRankingWithBaseLearner<PairwiseRankingConfiguration> { @Override public PairwiseRankingLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (PairwiseRankingLearningModel) super.train(dataset); } }
PairwiseRankingLearningAlgorithm extends AObjectRankingWithBaseLearner<PairwiseRankingConfiguration> { @Override public PairwiseRankingLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (PairwiseRankingLearningModel) super.train(dataset); } PairwiseRankingLearningAlgorithm(); }
PairwiseRankingLearningAlgorithm extends AObjectRankingWithBaseLearner<PairwiseRankingConfiguration> { @Override public PairwiseRankingLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (PairwiseRankingLearningModel) super.train(dataset); } PairwiseRankingLearningAlgorithm(); @Ove...
PairwiseRankingLearningAlgorithm extends AObjectRankingWithBaseLearner<PairwiseRankingConfiguration> { @Override public PairwiseRankingLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (PairwiseRankingLearningModel) super.train(dataset); } PairwiseRankingLearningAlgorithm(); @Ove...
@Test public void expectedRankRegressionTestCorrectInput() throws ParsingFailedException, TrainModelsFailedException, PredictionFailedException, LossException { File file = new File(getTestRessourcePathFor(OBJECT_RANKING_DATASET_B)); ExpectedRankRegression expectedRankRegressionAlgorithm = new ExpectedRankRegression();...
@Override public ExpectedRankRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (ExpectedRankRegressionLearningModel) super.train(dataset); }
ExpectedRankRegression extends AObjectRankingWithBaseLearner<ExpectedRankRegressionConfiguration> { @Override public ExpectedRankRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (ExpectedRankRegressionLearningModel) super.train(dataset); } }
ExpectedRankRegression extends AObjectRankingWithBaseLearner<ExpectedRankRegressionConfiguration> { @Override public ExpectedRankRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (ExpectedRankRegressionLearningModel) super.train(dataset); } ExpectedRankRegression(); }
ExpectedRankRegression extends AObjectRankingWithBaseLearner<ExpectedRankRegressionConfiguration> { @Override public ExpectedRankRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (ExpectedRankRegressionLearningModel) super.train(dataset); } ExpectedRankRegression(); @Ov...
ExpectedRankRegression extends AObjectRankingWithBaseLearner<ExpectedRankRegressionConfiguration> { @Override public ExpectedRankRegressionLearningModel train(IDataset<?, ?, ?> dataset) throws TrainModelsFailedException { return (ExpectedRankRegressionLearningModel) super.train(dataset); } ExpectedRankRegression(); @Ov...
@Test @Override public void testCorrectParameters() throws JsonParsingFailedException { List<JsonObject> listOfJsonObjects = getCorrectParameters(); for (int i = 0; i < listOfJsonObjects.size(); i++) { IAlgorithm algorithm = getAlgorithm(); try { algorithm.setParameters(listOfJsonObjects.get(i)); } catch (ParameterVali...
@Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); }
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } }
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } AAlgorithm(); AAlgorithm(String algorithmIdentifier); }
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } AAlgorithm(); AAlgorithm(String algorithmIdentifier); @Override AAlgorithmConfiguration getDefaultAlgorithmConfigura...
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } AAlgorithm(); AAlgorithm(String algorithmIdentifier); @Override AAlgorithmConfiguration getDefaultAlgorithmConfigura...
@Test @Override public void testWrongParameters() throws JsonParsingFailedException { List<Pair<String, JsonObject>> listOfPairsOfStringAndJsonObjects = getWrongParameters(); for (int i = 0; i < listOfPairsOfStringAndJsonObjects.size(); i++) { IAlgorithm algorithm = getAlgorithm(); try { algorithm.setParameters(listOfP...
@Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); }
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } }
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } AAlgorithm(); AAlgorithm(String algorithmIdentifier); }
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } AAlgorithm(); AAlgorithm(String algorithmIdentifier); @Override AAlgorithmConfiguration getDefaultAlgorithmConfigura...
AAlgorithm implements IAlgorithm { @Override public void setParameters(JsonObject jsonObject) throws ParameterValidationFailedException { getAlgorithmConfiguration().overrideConfiguration(jsonObject); } AAlgorithm(); AAlgorithm(String algorithmIdentifier); @Override AAlgorithmConfiguration getDefaultAlgorithmConfigura...
@Test public void testFitting() throws ParameterValidationFailedException, DistributionException, FittingDistributionFailedException { double[] expectedParameters = new double[] { 0.2, 0.1, 0.1, 0.1, 0.25, 0.25 }; int[] validItems = new int[] { 1, 2, 3, 4, 5, 6 }; PlackettLuceModel model = new PlackettLuceModel(expecte...
@Override public PlackettLuceModel fit(IDistributionSampleSet<Ranking> sampleSet) throws FittingDistributionFailedException { assertCorrectSampleSetType(sampleSet); initializeAlgorithm((PlackettLuceModelSampleSet) sampleSet); while (!shouldStop()) { updateParameters(); normalizeParameters(); updateDifferenceBetweenOldA...
PlackettLuceModelFittingAlgorithm extends ARankingDistributionFittingAlgorithm<PlackettLuceModelFittingAlgorithmConfiguration> { @Override public PlackettLuceModel fit(IDistributionSampleSet<Ranking> sampleSet) throws FittingDistributionFailedException { assertCorrectSampleSetType(sampleSet); initializeAlgorithm((Plack...
PlackettLuceModelFittingAlgorithm extends ARankingDistributionFittingAlgorithm<PlackettLuceModelFittingAlgorithmConfiguration> { @Override public PlackettLuceModel fit(IDistributionSampleSet<Ranking> sampleSet) throws FittingDistributionFailedException { assertCorrectSampleSetType(sampleSet); initializeAlgorithm((Plack...
PlackettLuceModelFittingAlgorithm extends ARankingDistributionFittingAlgorithm<PlackettLuceModelFittingAlgorithmConfiguration> { @Override public PlackettLuceModel fit(IDistributionSampleSet<Ranking> sampleSet) throws FittingDistributionFailedException { assertCorrectSampleSetType(sampleSet); initializeAlgorithm((Plack...
PlackettLuceModelFittingAlgorithm extends ARankingDistributionFittingAlgorithm<PlackettLuceModelFittingAlgorithmConfiguration> { @Override public PlackettLuceModel fit(IDistributionSampleSet<Ranking> sampleSet) throws FittingDistributionFailedException { assertCorrectSampleSetType(sampleSet); initializeAlgorithm((Plack...
@Test public void testGetSnippet() throws IOException { ResponseEntity<String> response = restTemplate.getForEntity(SNIPPET_ENDPOINT, String.class); Assert.assertEquals(HttpStatus.OK, response.getStatusCode()); Page<SnippetEntity> page = TestUtils.getObjectFromString(response.getBody(), new TypeReference<Page<SnippetEn...
@GetMapping(path = "/{id}") public SnippetEntity getSnippet(@PathVariable("id") String id) { return snippetService.getSnippet(id); }
Snippet { @GetMapping(path = "/{id}") public SnippetEntity getSnippet(@PathVariable("id") String id) { return snippetService.getSnippet(id); } }
Snippet { @GetMapping(path = "/{id}") public SnippetEntity getSnippet(@PathVariable("id") String id) { return snippetService.getSnippet(id); } }
Snippet { @GetMapping(path = "/{id}") public SnippetEntity getSnippet(@PathVariable("id") String id) { return snippetService.getSnippet(id); } @GetMapping() Page<SnippetEntity> getSnippets(@RequestParam(value = "from", defaultValue = "0") final int from, @RequestParam(value =...
Snippet { @GetMapping(path = "/{id}") public SnippetEntity getSnippet(@PathVariable("id") String id) { return snippetService.getSnippet(id); } @GetMapping() Page<SnippetEntity> getSnippets(@RequestParam(value = "from", defaultValue = "0") final int from, @RequestParam(value =...
@Test public void should_select_startup_category() { long selectedCategoryId = categories.get("AA1").id; navigator.selectCategory(selectedCategoryId); assertEquals(selectedCategoryId, navigator.selectedCategoryId); assertSelected(selectedCategoryId, "A1", "AA1"); }
public void selectCategory(long selectedCategoryId) { Map<Long, Category> map = categories.asMap(); Category selectedCategory = map.get(selectedCategoryId); if (selectedCategory != null) { Stack<Long> path = new Stack<>(); Category parent = selectedCategory.parent; while (parent != null) { path.push(parent.id); parent ...
CategoryTreeNavigator { public void selectCategory(long selectedCategoryId) { Map<Long, Category> map = categories.asMap(); Category selectedCategory = map.get(selectedCategoryId); if (selectedCategory != null) { Stack<Long> path = new Stack<>(); Category parent = selectedCategory.parent; while (parent != null) { path....
CategoryTreeNavigator { public void selectCategory(long selectedCategoryId) { Map<Long, Category> map = categories.asMap(); Category selectedCategory = map.get(selectedCategoryId); if (selectedCategory != null) { Stack<Long> path = new Stack<>(); Category parent = selectedCategory.parent; while (parent != null) { path....
CategoryTreeNavigator { public void selectCategory(long selectedCategoryId) { Map<Long, Category> map = categories.asMap(); Category selectedCategory = map.get(selectedCategoryId); if (selectedCategory != null) { Stack<Long> path = new Stack<>(); Category parent = selectedCategory.parent; while (parent != null) { path....
CategoryTreeNavigator { public void selectCategory(long selectedCategoryId) { Map<Long, Category> map = categories.asMap(); Category selectedCategory = map.get(selectedCategoryId); if (selectedCategory != null) { Stack<Long> path = new Stack<>(); Category parent = selectedCategory.parent; while (parent != null) { path....
@Test public void should_return_error_if_exchange_rate_not_available() { TransactionBuilder.withDb(db).account(a1).dateTime(DateTime.date(2012, 1, 10)).amount(1).create(); assertFalse(c.getAccountBalance(c1, a1.id).isError()); assertFalse(c.getAccountBalance(c3, a1.id).isError()); Total total = c.getAccountBalance(c2, ...
public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); }
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } }
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
@Test public void should_calculate_blotter_total_in_multiple_currencies() { Total[] totals = c.getTransactionsBalance(); assertEquals(2, totals.length); assertEquals(-700, totals[0].balance); assertEquals(-230, totals[1].balance); }
public Total[] getTransactionsBalance() { WhereFilter filter = this.filter; if (filter.getAccountId() == -1) { filter = excludeAccountsNotIncludedInTotalsAndSplits(filter); } try (Cursor c = db.db().query(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, BALANCE_PROJECTION, filter.getSelection(), filter.getSelectionArgs(), BALANCE_GR...
TransactionsTotalCalculator { public Total[] getTransactionsBalance() { WhereFilter filter = this.filter; if (filter.getAccountId() == -1) { filter = excludeAccountsNotIncludedInTotalsAndSplits(filter); } try (Cursor c = db.db().query(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, BALANCE_PROJECTION, filter.getSelection(), filter....
TransactionsTotalCalculator { public Total[] getTransactionsBalance() { WhereFilter filter = this.filter; if (filter.getAccountId() == -1) { filter = excludeAccountsNotIncludedInTotalsAndSplits(filter); } try (Cursor c = db.db().query(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, BALANCE_PROJECTION, filter.getSelection(), filter....
TransactionsTotalCalculator { public Total[] getTransactionsBalance() { WhereFilter filter = this.filter; if (filter.getAccountId() == -1) { filter = excludeAccountsNotIncludedInTotalsAndSplits(filter); } try (Cursor c = db.db().query(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, BALANCE_PROJECTION, filter.getSelection(), filter....
TransactionsTotalCalculator { public Total[] getTransactionsBalance() { WhereFilter filter = this.filter; if (filter.getAccountId() == -1) { filter = excludeAccountsNotIncludedInTotalsAndSplits(filter); } try (Cursor c = db.db().query(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, BALANCE_PROJECTION, filter.getSelection(), filter....
@Test public void should_calculate_account_total_in_home_currency() { assertEquals(a1t1_09th.fromAmount + a1t2_17th.fromAmount + a1t3_20th.fromAmount + a1t4_22nd.fromAmount + a1t5_23rd.fromAmount, c.getAccountBalance(c1, a1.id).balance); assertEquals((long) (a1t1_09th.originalFromAmount + r_c1c2_17th * a1t2_17th.fromAm...
public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); }
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } }
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
@Test public void should_calculate_account_total_in_home_currency_with_big_amounts() { TransactionBuilder.withDb(db).account(a1).dateTime(DateTime.date(2012, 1, 10)).amount(45000000000L).create(); assertEquals(45000000000L + (long) (-100f + 100f - 50f - 450f - 50f - 150f), c.getAccountBalance(c1, a1.id).balance); }
public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); }
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } }
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
TransactionsTotalCalculator { public Total getAccountBalance(Currency toCurrency, long accountId) { WhereFilter filter = selectedAccountOnly(this.filter, accountId); return getBalanceInHomeCurrency(V_BLOTTER_FOR_ACCOUNT_WITH_SPLITS, toCurrency, filter); } TransactionsTotalCalculator(DatabaseAdapter db, WhereFilter filt...
@Test public void TemplatesWithDifferentLength() { String template1 = "*{{a}}. Summa {{p}} RUB. {{*}}, MOSCOW. {{d}}. Dostupno {{b}}"; String template2 = "*{{a}}. Summa {{p}} RUB. NOVYY PROEKT, MOSCOW. {{d}}. Dostupno {{b}}"; String template3 = "*{{a}}. Summa {{p}} RUB. NOVYY PROEKT, MOSCOW. {{d}}. Dostupno {{b}}"; Str...
public Transaction createTransactionBySms(String addr, String fullSmsBody, TransactionStatus status, boolean updateNote) { List<SmsTemplate> addrTemplates = db.getSmsTemplatesByNumber(addr); for (final SmsTemplate t : addrTemplates) { String[] match = findTemplateMatches(t.template, fullSmsBody); if (match != null) { L...
SmsTransactionProcessor { public Transaction createTransactionBySms(String addr, String fullSmsBody, TransactionStatus status, boolean updateNote) { List<SmsTemplate> addrTemplates = db.getSmsTemplatesByNumber(addr); for (final SmsTemplate t : addrTemplates) { String[] match = findTemplateMatches(t.template, fullSmsBod...
SmsTransactionProcessor { public Transaction createTransactionBySms(String addr, String fullSmsBody, TransactionStatus status, boolean updateNote) { List<SmsTemplate> addrTemplates = db.getSmsTemplatesByNumber(addr); for (final SmsTemplate t : addrTemplates) { String[] match = findTemplateMatches(t.template, fullSmsBod...
SmsTransactionProcessor { public Transaction createTransactionBySms(String addr, String fullSmsBody, TransactionStatus status, boolean updateNote) { List<SmsTemplate> addrTemplates = db.getSmsTemplatesByNumber(addr); for (final SmsTemplate t : addrTemplates) { String[] match = findTemplateMatches(t.template, fullSmsBod...
SmsTransactionProcessor { public Transaction createTransactionBySms(String addr, String fullSmsBody, TransactionStatus status, boolean updateNote) { List<SmsTemplate> addrTemplates = db.getSmsTemplatesByNumber(addr); for (final SmsTemplate t : addrTemplates) { String[] match = findTemplateMatches(t.template, fullSmsBod...
@Test public void MultilineSms() { String template = "*{{a}}. Summa {{p}} RUB. NOVYY PROEKT, MOSCOW. {{d}}. Dostupno {{b}}{{*}}"; String sms = "Pokupka. Karta *5631. Summa 1250,77 RUB. NOVYY PROEKT, MOSCOW. 02.10.2017 14:19. Dostupno 34 202.82 RUB.\nTinkoff\n.ru"; String[] matches = SmsTransactionProcessor.findTemplate...
public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$1"); for (int i = 0; i < p...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
@Test public void TemplateWithWrongSpaces() { String smsTpl = "ECMC{{a}}<:D:>покупка{{P}}р TEREMOK METROPOLIS Баланс:{{b}}р"; String sms = "ECMC5431 01.10.17 19:50 покупка 550р TEREMOK METROPOLIS Баланс: 49820.45р"; String[] matches = SmsTransactionProcessor.findTemplateMatches(smsTpl, sms); Assert.assertArrayEquals(ne...
public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$1"); for (int i = 0; i < p...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
@Test public void TemplateWithAnyMatch() { String smsTpl = "ECMC{{A}}{{d}}покупка<:P:>р TEREMOK <::>Баланс:<:B:>р"; String sms = "ECMC5431 01.10.17 19:50 покупка 550р TEREMOK METROPOLIS Баланс: 49820.45р"; String[] matches = SmsTransactionProcessor.findTemplateMatches(smsTpl, sms); Assert.assertArrayEquals(new String[]...
public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$1"); for (int i = 0; i < p...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
@Test public void TemplateWithMultipleAnyMatch() { String smsTpl = "ECMC<:A:> <:D:> {{*}} <:P:>р TEREMOK<::><:B:>р"; String sms = "ECMC5431 01.10.17 19:50 покупка 550р TEREMOK METROPOLIS Баланс: 49820.45р"; String[] matches = SmsTransactionProcessor.findTemplateMatches(smsTpl, sms); Assert.assertArrayEquals(new String[...
public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$1"); for (int i = 0; i < p...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
@Test public void TemplateWithMultipleAnyMatchWithoutAccount() { String smsTpl = "<::> <:D:> {{*}} <:P:>р TEREMOK<::><:B:>р"; String sms = "ECMC5431 01.10.17 19:50 покупка 550р TEREMOK METROPOLIS Баланс: 49820.45р"; String[] matches = SmsTransactionProcessor.findTemplateMatches(smsTpl, sms); Assert.assertArrayEquals(ne...
public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$1"); for (int i = 0; i < p...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
@Test public void should_navigate_to_category() { long categoryId = categories.get("A").id; navigator.navigateTo(categoryId); assertSelected(categoryId, "A", "A1", "A2"); categoryId = categories.get("A1").id; navigator.navigateTo(categoryId); assertSelected(categoryId, "A1", "AA1"); categoryId = categories.get("AA1").i...
public boolean navigateTo(long categoryId) { Category selectedCategory = findCategory(categoryId); if (selectedCategory != null) { selectedCategoryId = selectedCategory.id; if (selectedCategory.hasChildren()) { categoriesStack.push(categories); categories = selectedCategory.children; tagCategories(selectedCategory); re...
CategoryTreeNavigator { public boolean navigateTo(long categoryId) { Category selectedCategory = findCategory(categoryId); if (selectedCategory != null) { selectedCategoryId = selectedCategory.id; if (selectedCategory.hasChildren()) { categoriesStack.push(categories); categories = selectedCategory.children; tagCategori...
CategoryTreeNavigator { public boolean navigateTo(long categoryId) { Category selectedCategory = findCategory(categoryId); if (selectedCategory != null) { selectedCategoryId = selectedCategory.id; if (selectedCategory.hasChildren()) { categoriesStack.push(categories); categories = selectedCategory.children; tagCategori...
CategoryTreeNavigator { public boolean navigateTo(long categoryId) { Category selectedCategory = findCategory(categoryId); if (selectedCategory != null) { selectedCategoryId = selectedCategory.id; if (selectedCategory.hasChildren()) { categoriesStack.push(categories); categories = selectedCategory.children; tagCategori...
CategoryTreeNavigator { public boolean navigateTo(long categoryId) { Category selectedCategory = findCategory(categoryId); if (selectedCategory != null) { selectedCategoryId = selectedCategory.id; if (selectedCategory.hasChildren()) { categoriesStack.push(categories); categories = selectedCategory.children; tagCategori...
@Test public void TemplateWithSpecialChars() { String smsTpl = "{{*}} {{d}} {{*}} {{p}}р TE{{R}}E{{MOK ME}TROP<:P:OL?$()[]/\\.*IS{{*}}{{b}}р"; String sms = "ECMC5431 01.10.17 19:50 покупка 555р TE{{R}}E{{MOK ME}TROP<:P:OL?$()[]/\\.*IS Баланс: 49820.45р"; String[] matches = SmsTransactionProcessor.findTemplateMatches(sm...
public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$1"); for (int i = 0; i < p...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
@Test public void MultipleAnyMatchWithoutAccountAndDate() { String smsTpl = "Pokupka{{*}}Summa {{p}} RUB. NOVYY PROEKT, MOSCOW{{*}}Dostupno {{b}} RUB.{{*}}"; String sms = "Pokupka. Karta *5631. Summa 250.00 RUB. NOVYY PROEKT, MOSCOW. 02.10.2017 14:19. Dostupno 34202.82 RUB. Tinkoff.ru"; String[] matches = SmsTransactio...
public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$1"); for (int i = 0; i < p...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
SmsTransactionProcessor { public static String[] findTemplateMatches(String template, final String sms) { String[] results = null; template = preprocessPatterns(template); final int[] phIndexes = findPlaceholderIndexes(template); if (phIndexes != null) { template = template.replaceAll("([.\\[\\]{}()*+\\-?^$|])", "\\\\$...
@Test public void FindingPlaceholderIndexes() { int[] indexes = SmsTransactionProcessor.findPlaceholderIndexes("Pokupka. Karta *<:A:>. Summa <:P:> RUB. NOVYY PROEKT, MOSCOW. <:D:>. Dostupno <:B:> RUB. Tinkoff.ru"); assertEquals(0, indexes[Placeholder.ACCOUNT.ordinal()]); assertEquals(1, indexes[Placeholder.PRICE.ordina...
static int[] findPlaceholderIndexes(String template) { Map<Integer, Placeholder> sorted = new TreeMap<>(); boolean foundPrice = false; for (Placeholder p : Placeholder.values()) { int i = template.indexOf(p.code); if (i >= 0) { if (p == PRICE) { foundPrice = true; } if (p != ANY) { sorted.put(i, p); } } } int[] result ...
SmsTransactionProcessor { static int[] findPlaceholderIndexes(String template) { Map<Integer, Placeholder> sorted = new TreeMap<>(); boolean foundPrice = false; for (Placeholder p : Placeholder.values()) { int i = template.indexOf(p.code); if (i >= 0) { if (p == PRICE) { foundPrice = true; } if (p != ANY) { sorted.put(...
SmsTransactionProcessor { static int[] findPlaceholderIndexes(String template) { Map<Integer, Placeholder> sorted = new TreeMap<>(); boolean foundPrice = false; for (Placeholder p : Placeholder.values()) { int i = template.indexOf(p.code); if (i >= 0) { if (p == PRICE) { foundPrice = true; } if (p != ANY) { sorted.put(...
SmsTransactionProcessor { static int[] findPlaceholderIndexes(String template) { Map<Integer, Placeholder> sorted = new TreeMap<>(); boolean foundPrice = false; for (Placeholder p : Placeholder.values()) { int i = template.indexOf(p.code); if (i >= 0) { if (p == PRICE) { foundPrice = true; } if (p != ANY) { sorted.put(...
SmsTransactionProcessor { static int[] findPlaceholderIndexes(String template) { Map<Integer, Placeholder> sorted = new TreeMap<>(); boolean foundPrice = false; for (Placeholder p : Placeholder.values()) { int i = template.indexOf(p.code); if (i >= 0) { if (p == PRICE) { foundPrice = true; } if (p != ANY) { sorted.put(...
@Test public void DifferentPrices() { Assert.assertEquals(new BigDecimal(5), toBigDecimal("5")); Assert.assertEquals(new BigDecimal("5.3"), toBigDecimal(" 5,3 ")); Assert.assertEquals(new BigDecimal("5.3"), toBigDecimal("5.3")); Assert.assertEquals(new BigDecimal("5000.3"), toBigDecimal("5.000,3")); Assert.assertEquals...
static BigDecimal toBigDecimal(final String value) { if (value != null) { final String EMPTY = ""; final char COMMA = ','; final String POINT_AS_STRING = "."; final char POINT = '.'; final String COMMA_AS_STRING = ","; String trimmed = value.trim(); boolean negativeNumber = ((trimmed.contains("(") && trimmed.contains("...
SmsTransactionProcessor { static BigDecimal toBigDecimal(final String value) { if (value != null) { final String EMPTY = ""; final char COMMA = ','; final String POINT_AS_STRING = "."; final char POINT = '.'; final String COMMA_AS_STRING = ","; String trimmed = value.trim(); boolean negativeNumber = ((trimmed.contains(...
SmsTransactionProcessor { static BigDecimal toBigDecimal(final String value) { if (value != null) { final String EMPTY = ""; final char COMMA = ','; final String POINT_AS_STRING = "."; final char POINT = '.'; final String COMMA_AS_STRING = ","; String trimmed = value.trim(); boolean negativeNumber = ((trimmed.contains(...
SmsTransactionProcessor { static BigDecimal toBigDecimal(final String value) { if (value != null) { final String EMPTY = ""; final char COMMA = ','; final String POINT_AS_STRING = "."; final char POINT = '.'; final String COMMA_AS_STRING = ","; String trimmed = value.trim(); boolean negativeNumber = ((trimmed.contains(...
SmsTransactionProcessor { static BigDecimal toBigDecimal(final String value) { if (value != null) { final String EMPTY = ""; final char COMMA = ','; final String POINT_AS_STRING = "."; final char POINT = '.'; final String COMMA_AS_STRING = ","; String trimmed = value.trim(); boolean negativeNumber = ((trimmed.contains(...
@Test public void should_detect_that_running_balance_is_broken() { TransactionBuilder.withDb(db).account(a1).amount(1000).create(); TransactionBuilder.withDb(db).account(a1).amount(2000).create(); TransactionBuilder.withDb(db).account(a2).amount(-100).create(); assertEquals(IntegrityCheck.Level.OK, integrity.check().le...
@Override public Result check() { if (isRunningBalanceBroken()) { return new Result(Level.ERROR, context.getString(R.string.integrity_error)); } else { return Result.OK; } }
IntegrityCheckRunningBalance implements IntegrityCheck { @Override public Result check() { if (isRunningBalanceBroken()) { return new Result(Level.ERROR, context.getString(R.string.integrity_error)); } else { return Result.OK; } } }
IntegrityCheckRunningBalance implements IntegrityCheck { @Override public Result check() { if (isRunningBalanceBroken()) { return new Result(Level.ERROR, context.getString(R.string.integrity_error)); } else { return Result.OK; } } IntegrityCheckRunningBalance(Context context, DatabaseAdapter db); }
IntegrityCheckRunningBalance implements IntegrityCheck { @Override public Result check() { if (isRunningBalanceBroken()) { return new Result(Level.ERROR, context.getString(R.string.integrity_error)); } else { return Result.OK; } } IntegrityCheckRunningBalance(Context context, DatabaseAdapter db); @Override Result check...
IntegrityCheckRunningBalance implements IntegrityCheck { @Override public Result check() { if (isRunningBalanceBroken()) { return new Result(Level.ERROR, context.getString(R.string.integrity_error)); } else { return Result.OK; } } IntegrityCheckRunningBalance(Context context, DatabaseAdapter db); @Override Result check...
@Test public void should_check_if_autobackup_has_been_disabled() { givenAutobackupReminderEnabledIs(true); givenAutobackupEnabledIs(false); givenFirstRunAfterRelease(); assertEquals(IntegrityCheck.Level.OK, integrity.check().level); sleepMillis(50); assertEquals(IntegrityCheck.Level.OK, integrity.check().level); sleepM...
@Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyAutobackupSucceeded(context); return new Result(Level....
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
@Test public void should_check_if_the_last_autobackup_has_failed() { givenAutobackupWarningEnabledIs(true); givenAutobackupEnabledIs(true); givenFirstRunAfterRelease(); assertEquals(IntegrityCheck.Level.OK, integrity.check().level); givenTheLastAutobackupHasFailed(); assertEquals(IntegrityCheck.Level.ERROR, integrity.c...
@Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyAutobackupSucceeded(context); return new Result(Level....
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
IntegrityCheckAutobackup implements IntegrityCheck { @Override public Result check() { if (MyPreferences.isAutoBackupEnabled(context)) { if (MyPreferences.isAutoBackupWarningEnabled(context)) { MyPreferences.AutobackupStatus status = MyPreferences.getAutobackupStatus(context); if (status.notify) { MyPreferences.notifyA...
@Test public void should_add_selected_currency_as_default_if_it_is_the_very_first_currency_added() { givenNoCurrenciesYetExist(); selector.addSelectedCurrency(1); Currency currency1 = db.load(Currency.class, currencyId); assertTrue(currency1.isDefault); selector.addSelectedCurrency(2); Currency currency2 = db.load(Curr...
public void addSelectedCurrency(int selectedCurrency) { if (selectedCurrency > 0 && selectedCurrency <= currencies.size()) { List<String> c = currencies.get(selectedCurrency-1); addSelectedCurrency(c); } else { listener.onCreated(0); } }
CurrencySelector { public void addSelectedCurrency(int selectedCurrency) { if (selectedCurrency > 0 && selectedCurrency <= currencies.size()) { List<String> c = currencies.get(selectedCurrency-1); addSelectedCurrency(c); } else { listener.onCreated(0); } } }
CurrencySelector { public void addSelectedCurrency(int selectedCurrency) { if (selectedCurrency > 0 && selectedCurrency <= currencies.size()) { List<String> c = currencies.get(selectedCurrency-1); addSelectedCurrency(c); } else { listener.onCreated(0); } } CurrencySelector(Context context, MyEntityManager em, OnCurrenc...
CurrencySelector { public void addSelectedCurrency(int selectedCurrency) { if (selectedCurrency > 0 && selectedCurrency <= currencies.size()) { List<String> c = currencies.get(selectedCurrency-1); addSelectedCurrency(c); } else { listener.onCreated(0); } } CurrencySelector(Context context, MyEntityManager em, OnCurrenc...
CurrencySelector { public void addSelectedCurrency(int selectedCurrency) { if (selectedCurrency > 0 && selectedCurrency <= currencies.size()) { List<String> c = currencies.get(selectedCurrency-1); addSelectedCurrency(c); } else { listener.onCreated(0); } } CurrencySelector(Context context, MyEntityManager em, OnCurrenc...
@Test public void should_split_category_name() { assertEquals("P1", extractCategoryName("P1")); assertEquals("P1:c1", extractCategoryName("P1:c1")); assertEquals("P1", extractCategoryName("P1/C2")); assertEquals("P1:c1", extractCategoryName("P1:c1/C2")); }
public static String extractCategoryName(String name) { int i = name.indexOf('/'); if (i != -1) { name = name.substring(0, i); } return name; }
CategoryCache { public static String extractCategoryName(String name) { int i = name.indexOf('/'); if (i != -1) { name = name.substring(0, i); } return name; } }
CategoryCache { public static String extractCategoryName(String name) { int i = name.indexOf('/'); if (i != -1) { name = name.substring(0, i); } return name; } }
CategoryCache { public static String extractCategoryName(String name) { int i = name.indexOf('/'); if (i != -1) { name = name.substring(0, i); } return name; } static String extractCategoryName(String name); void loadExistingCategories(DatabaseAdapter db); void insertCategories(DatabaseAdapter dbAdapter, Set<? extends...
CategoryCache { public static String extractCategoryName(String name) { int i = name.indexOf('/'); if (i != -1) { name = name.substring(0, i); } return name; } static String extractCategoryName(String name); void loadExistingCategories(DatabaseAdapter db); void insertCategories(DatabaseAdapter dbAdapter, Set<? extends...
@Test public void should_detect_multiple_account_currencies() { assertTrue(db.singleCurrencyOnly()); AccountBuilder.withDb(db).currency(a1.currency).title("Account2").create(); assertTrue(db.singleCurrencyOnly()); Currency c2 = CurrencyBuilder.withDb(db).name("USD").title("Dollar").symbol("$").create(); AccountBuilder....
public boolean singleCurrencyOnly() { long currencyId = getSingleCurrencyId(); return currencyId > 0; }
DatabaseAdapter extends MyEntityManager { public boolean singleCurrencyOnly() { long currencyId = getSingleCurrencyId(); return currencyId > 0; } }
DatabaseAdapter extends MyEntityManager { public boolean singleCurrencyOnly() { long currencyId = getSingleCurrencyId(); return currencyId > 0; } DatabaseAdapter(Context context); }
DatabaseAdapter extends MyEntityManager { public boolean singleCurrencyOnly() { long currencyId = getSingleCurrencyId(); return currencyId > 0; } DatabaseAdapter(Context context); void open(); void close(); int deleteAccount(long id); Transaction getTransaction(long id); Cursor getBlotter(WhereFilter filter); Cursor ge...
DatabaseAdapter extends MyEntityManager { public boolean singleCurrencyOnly() { long currencyId = getSingleCurrencyId(); return currencyId > 0; } DatabaseAdapter(Context context); void open(); void close(); int deleteAccount(long id); Transaction getTransaction(long id); Cursor getBlotter(WhereFilter filter); Cursor ge...
@Test public void should_not_return_split_category_as_parent_when_editing_a_category() { List<Category> list = db.getCategoriesWithoutSubtreeAsList(categoriesMap.get("A").id); for (Category category : list) { assertFalse("Should not be split", category.isSplit()); } }
public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return list; } }
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
@Test public void should_return_only_valid_parent_categories_when_editing_a_category() { List<Category> list = db.getCategoriesWithoutSubtreeAsList(categoriesMap.get("A").id); assertEquals(2, list.size()); assertEquals(Category.NO_CATEGORY_ID, list.get(0).id); assertEquals(categoriesMap.get("B").id, list.get(1).id); }
public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return list; } }
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
DatabaseAdapter extends MyEntityManager { public List<Category> getCategoriesWithoutSubtreeAsList(long categoryId) { List<Category> list = new ArrayList<>(); try (Cursor c = getCategoriesWithoutSubtree(categoryId, true)) { while (c.moveToNext()) { Category category = Category.formCursor(c); list.add(category); } return...
@Test public void should_return_id_of_the_nearest_transaction_which_is_older_than_specified_date() { a2 = AccountBuilder.createDefault(db); Transaction t8 = TransactionBuilder.withDb(db).dateTime(DateTime.date(2012, 5, 25).at(17, 30, 45, 0)).account(a2).amount(-234).create(); Transaction t7 = TransactionBuilder.withDb(...
public long findNearestOlderTransactionId(Account account, long date) { return DatabaseUtils.rawFetchId(this, "select _id from v_blotter where from_account_id=? and datetime<=? order by datetime desc limit 1", new String[]{String.valueOf(account.id), String.valueOf(DateUtils.atDayEnd(date))}); }
DatabaseAdapter extends MyEntityManager { public long findNearestOlderTransactionId(Account account, long date) { return DatabaseUtils.rawFetchId(this, "select _id from v_blotter where from_account_id=? and datetime<=? order by datetime desc limit 1", new String[]{String.valueOf(account.id), String.valueOf(DateUtils.at...
DatabaseAdapter extends MyEntityManager { public long findNearestOlderTransactionId(Account account, long date) { return DatabaseUtils.rawFetchId(this, "select _id from v_blotter where from_account_id=? and datetime<=? order by datetime desc limit 1", new String[]{String.valueOf(account.id), String.valueOf(DateUtils.at...
DatabaseAdapter extends MyEntityManager { public long findNearestOlderTransactionId(Account account, long date) { return DatabaseUtils.rawFetchId(this, "select _id from v_blotter where from_account_id=? and datetime<=? order by datetime desc limit 1", new String[]{String.valueOf(account.id), String.valueOf(DateUtils.at...
DatabaseAdapter extends MyEntityManager { public long findNearestOlderTransactionId(Account account, long date) { return DatabaseUtils.rawFetchId(this, "select _id from v_blotter where from_account_id=? and datetime<=? order by datetime desc limit 1", new String[]{String.valueOf(account.id), String.valueOf(DateUtils.at...
@Test public void should_delete_old_transactions() { a2 = AccountBuilder.createDefault(db); TransactionBuilder.withDb(db).dateTime(DateTime.date(2012, 5, 25).at(17, 30, 45, 0)).account(a2).amount(-234).create(); TransactionBuilder.withDb(db).dateTime(DateTime.date(2012, 5, 24).at(12, 30, 0, 0)).account(a1).amount(-100)...
public void deleteOldTransactions(Account account, long date) { SQLiteDatabase db = db(); long dayEnd = DateUtils.atDayEnd(date); db.delete("transactions", "from_account_id=? and datetime<=? and is_template=0", new String[]{String.valueOf(account.id), String.valueOf(dayEnd)}); db.delete("running_balance", "account_id=?...
DatabaseAdapter extends MyEntityManager { public void deleteOldTransactions(Account account, long date) { SQLiteDatabase db = db(); long dayEnd = DateUtils.atDayEnd(date); db.delete("transactions", "from_account_id=? and datetime<=? and is_template=0", new String[]{String.valueOf(account.id), String.valueOf(dayEnd)}); ...
DatabaseAdapter extends MyEntityManager { public void deleteOldTransactions(Account account, long date) { SQLiteDatabase db = db(); long dayEnd = DateUtils.atDayEnd(date); db.delete("transactions", "from_account_id=? and datetime<=? and is_template=0", new String[]{String.valueOf(account.id), String.valueOf(dayEnd)}); ...
DatabaseAdapter extends MyEntityManager { public void deleteOldTransactions(Account account, long date) { SQLiteDatabase db = db(); long dayEnd = DateUtils.atDayEnd(date); db.delete("transactions", "from_account_id=? and datetime<=? and is_template=0", new String[]{String.valueOf(account.id), String.valueOf(dayEnd)}); ...
DatabaseAdapter extends MyEntityManager { public void deleteOldTransactions(Account account, long date) { SQLiteDatabase db = db(); long dayEnd = DateUtils.atDayEnd(date); db.delete("transactions", "from_account_id=? and datetime<=? and is_template=0", new String[]{String.valueOf(account.id), String.valueOf(dayEnd)}); ...
@Test public void should_find_latest_transaction_date_for_an_account() { Account a2 = AccountBuilder.createDefault(db); Account a3 = AccountBuilder.createDefault(db); Account a4 = AccountBuilder.createDefault(db); TransactionBuilder.withDb(db).dateTime(DateTime.date(2012, 5, 25).at(17, 30, 45, 0)).account(a2).amount(-2...
public long findLatestTransactionDate(long accountId) { return DatabaseUtils.rawFetchLongValue(this, "select datetime from running_balance where account_id=? order by datetime desc limit 1", new String[]{String.valueOf(accountId)}); }
DatabaseAdapter extends MyEntityManager { public long findLatestTransactionDate(long accountId) { return DatabaseUtils.rawFetchLongValue(this, "select datetime from running_balance where account_id=? order by datetime desc limit 1", new String[]{String.valueOf(accountId)}); } }
DatabaseAdapter extends MyEntityManager { public long findLatestTransactionDate(long accountId) { return DatabaseUtils.rawFetchLongValue(this, "select datetime from running_balance where account_id=? order by datetime desc limit 1", new String[]{String.valueOf(accountId)}); } DatabaseAdapter(Context context); }
DatabaseAdapter extends MyEntityManager { public long findLatestTransactionDate(long accountId) { return DatabaseUtils.rawFetchLongValue(this, "select datetime from running_balance where account_id=? order by datetime desc limit 1", new String[]{String.valueOf(accountId)}); } DatabaseAdapter(Context context); void open...
DatabaseAdapter extends MyEntityManager { public long findLatestTransactionDate(long accountId) { return DatabaseUtils.rawFetchLongValue(this, "select datetime from running_balance where account_id=? order by datetime desc limit 1", new String[]{String.valueOf(accountId)}); } DatabaseAdapter(Context context); void open...
@Test public void should_restore_system_entities() { givenSystemEntitiesHaveBeenDeleted(); db.restoreSystemEntities(); for (MyEntity e : systemEntities) { MyEntity myEntity = db.get(e.getClass(), e.id); assertNotNull(e.getClass() + ":" + e.getTitle(), myEntity); } Category c = db.get(Category.class, Category.NO_CATEGOR...
public void restoreSystemEntities() { SQLiteDatabase db = db(); db.beginTransaction(); try { restoreCategories(); restoreAttributes(); restoreProjects(); restoreLocations(); db.setTransactionSuccessful(); } catch (Exception e) { Log.e("Financisto", "Unable to restore system entities", e); } finally { db.endTransaction(...
DatabaseAdapter extends MyEntityManager { public void restoreSystemEntities() { SQLiteDatabase db = db(); db.beginTransaction(); try { restoreCategories(); restoreAttributes(); restoreProjects(); restoreLocations(); db.setTransactionSuccessful(); } catch (Exception e) { Log.e("Financisto", "Unable to restore system ent...
DatabaseAdapter extends MyEntityManager { public void restoreSystemEntities() { SQLiteDatabase db = db(); db.beginTransaction(); try { restoreCategories(); restoreAttributes(); restoreProjects(); restoreLocations(); db.setTransactionSuccessful(); } catch (Exception e) { Log.e("Financisto", "Unable to restore system ent...
DatabaseAdapter extends MyEntityManager { public void restoreSystemEntities() { SQLiteDatabase db = db(); db.beginTransaction(); try { restoreCategories(); restoreAttributes(); restoreProjects(); restoreLocations(); db.setTransactionSuccessful(); } catch (Exception e) { Log.e("Financisto", "Unable to restore system ent...
DatabaseAdapter extends MyEntityManager { public void restoreSystemEntities() { SQLiteDatabase db = db(); db.beginTransaction(); try { restoreCategories(); restoreAttributes(); restoreProjects(); restoreLocations(); db.setTransactionSuccessful(); } catch (Exception e) { Log.e("Financisto", "Unable to restore system ent...
@Test public void account_number_lookup() { Account account = AccountBuilder.withDb(db) .currency(CurrencyBuilder.createDefault(db)) .title("SB").issuer("Sber").number("1111-2222-3333-5431").create(); final List<Long> res = db.findAccountsByNumber("5431"); assertEquals(1, res.size()); assertEquals((Long) account.id, re...
public List<Long> findAccountsByNumber(String numberEnding) { try (Cursor c = db().rawQuery( "select " + AccountColumns.ID + " from " + ACCOUNT_TABLE + " where " + AccountColumns.NUMBER + " like ?", new String[]{"%" + numberEnding})) { List<Long> res = new ArrayList<>(c.getCount()); while (c.moveToNext()) { res.add(c.g...
DatabaseAdapter extends MyEntityManager { public List<Long> findAccountsByNumber(String numberEnding) { try (Cursor c = db().rawQuery( "select " + AccountColumns.ID + " from " + ACCOUNT_TABLE + " where " + AccountColumns.NUMBER + " like ?", new String[]{"%" + numberEnding})) { List<Long> res = new ArrayList<>(c.getCoun...
DatabaseAdapter extends MyEntityManager { public List<Long> findAccountsByNumber(String numberEnding) { try (Cursor c = db().rawQuery( "select " + AccountColumns.ID + " from " + ACCOUNT_TABLE + " where " + AccountColumns.NUMBER + " like ?", new String[]{"%" + numberEnding})) { List<Long> res = new ArrayList<>(c.getCoun...
DatabaseAdapter extends MyEntityManager { public List<Long> findAccountsByNumber(String numberEnding) { try (Cursor c = db().rawQuery( "select " + AccountColumns.ID + " from " + ACCOUNT_TABLE + " where " + AccountColumns.NUMBER + " like ?", new String[]{"%" + numberEnding})) { List<Long> res = new ArrayList<>(c.getCoun...
DatabaseAdapter extends MyEntityManager { public List<Long> findAccountsByNumber(String numberEnding) { try (Cursor c = db().rawQuery( "select " + AccountColumns.ID + " from " + ACCOUNT_TABLE + " where " + AccountColumns.NUMBER + " like ?", new String[]{"%" + numberEnding})) { List<Long> res = new ArrayList<>(c.getCoun...
@Test public void should_pay_1_when_buy_espresso() { Espresso espresso = new Espresso(false, false); assertTrue(espresso.cost() == 4.0); }
public abstract double cost();
Beverage { public abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
@Test public void should_turn_off_stereo_when_press_third_off_button() { Stereo stereo = new Stereo(); RemoteControl remoteControl = new RemoteControl(null, null, stereo); remoteControl.off(3); assertFalse(stereo.getCdStatus()); assertFalse(stereo.getCdStatus()); assertEquals(0, stereo.getVolume()); }
public void off(int slot) { if (slot == 1) light.off(); if (slot == 2) ceiling.off(); if (slot == 3) stereo.off(); }
RemoteControl { public void off(int slot) { if (slot == 1) light.off(); if (slot == 2) ceiling.off(); if (slot == 3) stereo.off(); } }
RemoteControl { public void off(int slot) { if (slot == 1) light.off(); if (slot == 2) ceiling.off(); if (slot == 3) stereo.off(); } RemoteControl(Light light, Ceiling ceiling, Stereo stereo); }
RemoteControl { public void off(int slot) { if (slot == 1) light.off(); if (slot == 2) ceiling.off(); if (slot == 3) stereo.off(); } RemoteControl(Light light, Ceiling ceiling, Stereo stereo); void on(int slot); void off(int slot); }
RemoteControl { public void off(int slot) { if (slot == 1) light.off(); if (slot == 2) ceiling.off(); if (slot == 3) stereo.off(); } RemoteControl(Light light, Ceiling ceiling, Stereo stereo); void on(int slot); void off(int slot); }
@Test public void gumball_machine_status_should_be_no_quarter_at_start() { GumballMachine gumballMachine = new GumballMachine(10, MachineStatus.NO_QUARTER); assertEquals(MachineStatus.NO_QUARTER, gumballMachine.getState()); }
public MachineStatus getState() { return State; }
GumballMachine { public MachineStatus getState() { return State; } }
GumballMachine { public MachineStatus getState() { return State; } GumballMachine(int gumballNum, MachineStatus machineStatus); }
GumballMachine { public MachineStatus getState() { return State; } GumballMachine(int gumballNum, MachineStatus machineStatus); int getGumballNum(); void setGumballNum(int gumballNum); MachineStatus getState(); void setState(MachineStatus state); String insertQuarter(); String turnCrank(); String dispense(); String eje...
GumballMachine { public MachineStatus getState() { return State; } GumballMachine(int gumballNum, MachineStatus machineStatus); int getGumballNum(); void setGumballNum(int gumballNum); MachineStatus getState(); void setState(MachineStatus state); String insertQuarter(); String turnCrank(); String dispense(); String eje...
@Test public void seeding_machine_should_start_if_temperature_over_5_degree() { weatherData.measurementsChanged(10, 0, 0); assertTrue(seedingMachine.getStatus()); }
public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); }
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } }
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
@Test public void reaping_machine_should_start_if_temperature_over_5_degree_and_humidity_over_65() { weatherData.measurementsChanged(10, 70, 0); assertTrue(reapingMachine.getStatus()); }
public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); }
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } }
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
@Test public void water_machine_should_start_if_temperature_over_10_degree_and_humidity_less_than_55_and_wind_power_less_than_4() { weatherData.measurementsChanged(12, 50, 2); assertTrue(wateringMachine.getStatus()); }
public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); }
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } }
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
WeatherData { public void measurementsChanged(int temp, int humidity, int windPower) { if (temp > 5) { seedingMachine.start(); if (humidity > 65) reapingMachine.start(); } if (temp > 10 && humidity < 55 && windPower < 4) wateringMachine.start(); } WeatherData(SeedingMachine seedingMachine, ReapingMachine reapingMachine...
@Test public void should_calc_health_rating_Ingredient() { assertEquals(1, flour.getHealthRating()); }
public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); }
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } }
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); }
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<Strin...
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<Strin...
@Test public void should_calc_protein_for_Ingredient() { assertEquals("100.0 g", flour.getProtein()); }
public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); }
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } }
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); }
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<String> getProte...
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<String> getProte...
@Test public void should_calc_calory_for_Ingredient() { assertEquals("10 J", flour.getCalory()); }
public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; }
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } }
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } MenuItem(List<Ingredient> ingredients); }
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); ...
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); ...
@Test public void should_calc_health_rating_for_MenuItem() { assertEquals(2, moonCake.getHealthRating().size()); assertTrue(moonCake.getHealthRating().contains(1)); assertTrue(moonCake.getHealthRating().contains(2)); }
public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); }
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } }
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); }
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<Strin...
MenuItem { public List<Integer> getHealthRating() { return ingredients.stream() .map(Ingredient::getHealthRating) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<Strin...
@Test public void should_calc_protein_for_MenuItem() { assertEquals(2, moonCake.getProtein().size()); assertTrue(moonCake.getProtein().contains("100.0 g")); assertTrue(moonCake.getProtein().contains("200.0 g")); }
public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); }
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } }
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); }
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<String> getProte...
MenuItem { public List<String> getProtein() { return ingredients.stream() .map(Ingredient::getProtein) .collect(Collectors.toList()); } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); void Taste(); void Cook(); List<Integer> getHealthRating(); List<String> getProte...
@Test public void should_pay_5_when_buy_espresso_with_milk() { Espresso espresso = new Espresso(true, false); assertTrue(espresso.cost() == 5.0); }
public abstract double cost();
Beverage { public abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
@Test public void should_calc_calory_for_MenuItem() { assertEquals(3, moonCake.getCalory().size()); assertTrue(moonCake.getCalory().contains("10 J")); assertTrue(moonCake.getCalory().contains("20 J")); assertTrue(moonCake.getCalory().contains("Cooking will double calories!!!")); }
public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; }
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } }
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } MenuItem(List<Ingredient> ingredients); }
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); ...
MenuItem { public List<String> getCalory() { List<String> calories = ingredients.stream() .map(Ingredient::getCalory) .collect(Collectors.toList()); calories.add("Cooking will double calories!!!"); return calories; } MenuItem(List<Ingredient> ingredients); void AddToPot(); void AddWater(); void AddOil(); void Smell(); ...
@Test public void should_get_alert_message_if_people_names_include_don() { List<String> peopleNames = Arrays.asList("Don", "Kent"); UsingReturn usingReturn = new UsingReturn(); String alertMessage = usingReturn.checkSecurity(peopleNames); assertEquals("AlertDon", alertMessage); }
public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
@Test public void should_get_alert_message_if_people_names_include_john() { List<String> peopleNames = Arrays.asList("John", "Kent"); UsingReturn usingReturn = new UsingReturn(); String alertMessage = usingReturn.checkSecurity(peopleNames); assertEquals("AlertJohn", alertMessage); }
public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
@Test public void should_alert_first_matched_people() { List<String> peopleNames = Arrays.asList("John", "Don"); UsingReturn usingReturn = new UsingReturn(); String alertMessage = usingReturn.checkSecurity(peopleNames); assertEquals("AlertJohn", alertMessage); }
public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
@Test public void should_not_get_alert_message_if_people_names_does_include_don_and_john() { List<String> peopleNames = Arrays.asList("Martin", "Kent"); UsingReturn usingReturn = new UsingReturn(); String alertMessage = usingReturn.checkSecurity(peopleNames); assertEquals("", alertMessage); }
public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } }
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
UsingReturn { public String checkSecurity(List<String> people) { String found = ""; for (String name : people) { if (found == "") { if (name.equals("Don")) { sendAlert(); found = "Don"; } if (name.equals("John")) { sendAlert(); found = "John"; } } } return someLaterCode(found); } String checkSecurity(List<String> peop...
@Test public void should_get_zero_disability_amount_given_seniority_less_than_two() { OrsExample consolidateConditionalExpression = new OrsExample(1, 0, false); assertEquals(0, consolidateConditionalExpression.disabilityAmount(), 0); }
public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
@Test public void should_get_zero_disability_amount_given_month_disabled_more_than_12() { OrsExample consolidateConditionalExpression = new OrsExample(2, 13, false); assertEquals(0, consolidateConditionalExpression.disabilityAmount(), 0); }
public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
@Test public void should_get_zero_disability_amount_given_is_part_time() { OrsExample consolidateConditionalExpression = new OrsExample(2, 1, true); assertEquals(0, consolidateConditionalExpression.disabilityAmount(), 0); }
public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
@Test public void should_get_ten_disability_amount_given_seniority_greater_than_one_and_disabled_less_than_13_and_is_not_part_time() { OrsExample consolidateConditionalExpression = new OrsExample(2, 1, false); assertEquals(10, consolidateConditionalExpression.disabilityAmount(), 0); }
public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
OrsExample { public double disabilityAmount() { if (seniority < 2) return 0; if (monthsDisabled > 12) return 0; if (isPartTime) return 0; return disabilityAmount; } OrsExample(double seniority, double monthsDisabled, boolean isPartTime); double disabilityAmount(); }
@Test public void should_get_1_given_is_on_vacation_and_length_of_service_greater_than_10() { AndsExample andsExample = new AndsExample(11, true); assertEquals(1, andsExample.getCharge(), 0); }
public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); double getCharge(); }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); double getCharge(); }
@Test public void should_pay_7_when_buy_espresso_with_mocha() { Espresso espresso = new Espresso(false, true); assertTrue(espresso.cost() == 7.0); }
public abstract double cost();
Beverage { public abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
@Test public void should_get_point_5_given_is_not_on_vacation() { AndsExample andsExample = new AndsExample(11, false); assertEquals(0.5, andsExample.getCharge(), 0); }
public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); double getCharge(); }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); double getCharge(); }
@Test public void should_get_point_5_given_length_of_service_not_greater_than_10() { AndsExample andsExample = new AndsExample(5, true); assertEquals(0.5, andsExample.getCharge(), 0); }
public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); double getCharge(); }
AndsExample { public double getCharge() { if (onVacation()) if (lengthOfService() > 10) return 1; return 0.5; } AndsExample(double lengthOfService, boolean onVacation); double getCharge(); }
@Test public void should_get_disability_amount_given_is_special_deal() { ConsolidateDuplicateConditionalFragments consolidateDuplicateConditionalFragments = new ConsolidateDuplicateConditionalFragments(true, 10); assertEquals(10.5, consolidateDuplicateConditionalFragments.disabilityAmount(), 0); }
public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } ConsolidateDuplicateConditionalFragments(boolean isSpecialDeal, double price); }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } ConsolidateDuplicateConditionalFragments(boolean isSpecialDeal, double price); double disabilityAmount(); }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } ConsolidateDuplicateConditionalFragments(boolean isSpecialDeal, double price); double disabilityAmount(); }
@Test public void should_get_zero_disability_amount_given_month_disabled_more_than_12() { ConsolidateDuplicateConditionalFragments consolidateDuplicateConditionalFragments = new ConsolidateDuplicateConditionalFragments(false, 10); assertEquals(10.8, consolidateDuplicateConditionalFragments.disabilityAmount(), 0); }
public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } ConsolidateDuplicateConditionalFragments(boolean isSpecialDeal, double price); }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } ConsolidateDuplicateConditionalFragments(boolean isSpecialDeal, double price); double disabilityAmount(); }
ConsolidateDuplicateConditionalFragments { public double disabilityAmount() { if (isSpecialDeal()) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } return total; } ConsolidateDuplicateConditionalFragments(boolean isSpecialDeal, double price); double disabilityAmount(); }
@Test public void should_get_summer_charge_given_date_is_in_summer() { ChargeCalculator chargeCalculator = new ChargeCalculator(); double charge = chargeCalculator.getCharge(new Date(2011, 7, 1), 100); assertEquals(200, charge, 0); }
public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } double getCharge(Date date, double quantity); }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } double getCharge(Date date, double quantity); }
@Test public void should_get_winter_charge_given_date_is_not_in_summer() { ChargeCalculator chargeCalculator = new ChargeCalculator(); double charge = chargeCalculator.getCharge(new Date(2011, 11, 1), 100); assertEquals(400, charge, 0); }
public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } double getCharge(Date date, double quantity); }
ChargeCalculator { public double getCharge(Date date, double quantity) { double charge; if (date.before(SUMMER_START) || date.after(SUMMER_END)) charge = quantity * winterRate + winterServiceCharge; else charge = quantity * summerRate; return charge; } double getCharge(Date date, double quantity); }
@Test public void should_get_basic_statement_given_does_not_have_customer() { Site site = new Site(null); Client client = new Client(site); assertEquals("Basic Plan occupant 0", client.getStatement()); }
public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " + weeksDel...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
@Test public void should_get_customer_statement_given_has_customer() { Site site = new Site(new Customer()); Client client = new Client(site); assertEquals("Real Plan Name 100", client.getStatement()); }
public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " + weeksDel...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
Client { public String getStatement() { String plan = customer() == null ? "Basic Plan" : customer().getPlan(); String customerName = customer() == null ? "occupant" : customer().getName(); int weeksDelinquent = customer() == null ? 0 : customer().getWeeksDelinquentInLastYear(); return plan + " " + customerName + " " +...
@Test public void should_get_pay_amount_for_engineer_given_type_is_engineer() throws Exception { Employee employee = new Employee(EmployeeType.ENGINEER); assertEquals(100, employee.payAmount()); }
public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } }
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } }
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
@Test public void should_get_pay_amount_for_sales_man_given_type_is_sales_man() throws Exception { Employee employee = new Employee(EmployeeType.SALESMAN); assertEquals(120, employee.payAmount()); }
public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } }
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } }
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
@Test public void should_pay_8_when_buy_espresso_with_milk_and_mocha() { Espresso espresso = new Espresso(true, true); assertTrue(espresso.cost() == 8.0); }
public abstract double cost();
Beverage { public abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
Beverage { public abstract double cost(); protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
@Test public void should_get_pay_amount_for_manager_given_type_is_manager() throws Exception { Employee employee = new Employee(EmployeeType.MANAGER); assertEquals(150, employee.payAmount()); }
public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } }
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } }
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
Employee { public int payAmount() throws Exception { switch (employeeType.getEmployeeCode()) { case EmployeeType.ENGINEER: return MonthlySalary; case EmployeeType.SALESMAN: return MonthlySalary + Commission; case EmployeeType.MANAGER: return MonthlySalary + Bonus; default: throw new Exception(); } } Employee(int type);...
@Test public void should_get_dead_amount_pay_given_is_dead() { ReplaceNestedConditionalWithGuardClauses replaceNestedConditionalWithGuardClauses = new ReplaceNestedConditionalWithGuardClauses(true, false, false); assertEquals(400, replaceNestedConditionalWithGuardClauses.getPayAmount(), 0); }
public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
@Test public void should_get_separated_amount_pay_given_is_separated_and_not_dead() { ReplaceNestedConditionalWithGuardClauses replaceNestedConditionalWithGuardClauses = new ReplaceNestedConditionalWithGuardClauses(false, true, false); assertEquals(300, replaceNestedConditionalWithGuardClauses.getPayAmount(), 0); }
public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
@Test public void should_get_separated_amount_pay_given_is_retired_and_not_dead_and_not_seperated() { ReplaceNestedConditionalWithGuardClauses replaceNestedConditionalWithGuardClauses = new ReplaceNestedConditionalWithGuardClauses(false, false, true); assertEquals(200, replaceNestedConditionalWithGuardClauses.getPayAmo...
public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
@Test public void should_get_normal_amount_pay_given_is_not_retired_and_not_dead_and_not_seperated() { ReplaceNestedConditionalWithGuardClauses replaceNestedConditionalWithGuardClauses = new ReplaceNestedConditionalWithGuardClauses(false, false, false); assertEquals(100, replaceNestedConditionalWithGuardClauses.getPayA...
public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } }
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
ReplaceNestedConditionalWithGuardClauses { public double getPayAmount() { double result; if (isDead) result = deadAmount(); else { if (isSeparated) result = separatedAmount(); else { if (isRetired) result = retiredAmount(); else result = normalPayAmount(); } } return result; } ReplaceNestedConditionalWithGuardClauses(b...
@Test public void should_get_zero_adjusted_capital_given_capital_is_less_than_zero() { ReversingTheConditions reversingTheConditions = new ReversingTheConditions(-1, 10, 10, 10); assertEquals(0, reversingTheConditions.getAdjustedCapital(), 0); }
public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
@Test public void should_get_zero_adjusted_capital_given_init_rate_is_less_than_zero() { ReversingTheConditions reversingTheConditions = new ReversingTheConditions(10, -1, 10, 10); assertEquals(0, reversingTheConditions.getAdjustedCapital(), 0); }
public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
@Test public void should_get_zero_adjusted_capital_given_duration_is_less_than_zero() { ReversingTheConditions reversingTheConditions = new ReversingTheConditions(10, 10, -1, 10); assertEquals(0, reversingTheConditions.getAdjustedCapital(), 0); }
public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
@Test public void should_get_adjusted_capital_given_duration_and_capital_and_init_rate_all_are_greater_than_zero() { ReversingTheConditions reversingTheConditions = new ReversingTheConditions(10, 10, 5, 10); assertEquals(4, reversingTheConditions.getAdjustedCapital(), 0); }
public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); }
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
ReversingTheConditions { public double getAdjustedCapital() { double result = 0.0; if (capital > 0.0) { if (intRate > 0.0 && duration > 0.0) { result = (income / duration) * AdjFactor; } } return result; } ReversingTheConditions(double capital, double intRate, double duration, double income); double getAdjustedCapital(...
@Test public void should_get_true_given_amount_over_1000() { InlineTemp inlineTemp = new InlineTemp(2000); assertTrue(inlineTemp.isAmountOver1000()); }
public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } InlineTemp(int amount); }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } InlineTemp(int amount); boolean isAmountOver1000(); }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } InlineTemp(int amount); boolean isAmountOver1000(); }
@Test public void should_return_espresso_when_get_espresso_description() { Espresso espresso = new Espresso(false, false); assertTrue(Objects.equals(espresso.getDescription(), "Espresso")); }
public String getDescription() { return ""; }
Beverage { public String getDescription() { return ""; } }
Beverage { public String getDescription() { return ""; } protected Beverage(boolean milk, boolean mocha); }
Beverage { public String getDescription() { return ""; } protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
Beverage { public String getDescription() { return ""; } protected Beverage(boolean milk, boolean mocha); boolean isMilk(); boolean isMocha(); String getDescription(); abstract double cost(); }
@Test public void should_get_false_given_amount_less_than_1000() { InlineTemp inlineTemp = new InlineTemp(500); assertFalse(inlineTemp.isAmountOver1000()); }
public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } InlineTemp(int amount); }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } InlineTemp(int amount); boolean isAmountOver1000(); }
InlineTemp { public boolean isAmountOver1000() { double amount = order.getAmount(); return amount > 1000; } InlineTemp(int amount); boolean isAmountOver1000(); }
@Test public void should_get_rating_2_given_more_than_five_late_deliveries() { final int numberOfLateDeliveries = 6; InlineMethod inlineMethod = new InlineMethod(numberOfLateDeliveries); assertEquals(2, inlineMethod.getRating()); }
public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } InlineMethod(double numberOfLateDeliveries); }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } InlineMethod(double numberOfLateDeliveries); int getRating(); }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } InlineMethod(double numberOfLateDeliveries); int getRating(); }
@Test public void should_get_rating_1_given_less_than_five_late_deliveries() { final int numberOfLateDeliveries = 4; InlineMethod inlineMethod = new InlineMethod(numberOfLateDeliveries); assertEquals(1, inlineMethod.getRating()); }
public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } InlineMethod(double numberOfLateDeliveries); }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } InlineMethod(double numberOfLateDeliveries); int getRating(); }
InlineMethod { public int getRating() { return (moreThanFiveLateDeliveries()) ? 2 : 1; } InlineMethod(double numberOfLateDeliveries); int getRating(); }
@Test public void should_get_right_customer_owns() { String expectedCustomerOwns = "****/n**Customer Owns**/n****/nname:ExtractMethod/namount:140.0"; List<Order> orders = Arrays.asList(new Order(10), new Order(20)); ExtractMethod extractMethod = new ExtractMethod(orders); String owns = extractMethod.printOwning("Extrac...
public String printOwning(String name, int previousAmount) { String customerOwns = ""; double outstanding = 10 + previousAmount; customerOwns += "****/n"; customerOwns += "**Customer Owns**/n"; customerOwns += "****/n"; for (Order order : orders) { outstanding += order.getAmount(); } customerOwns += "name:" + name + "/...
ExtractMethod { public String printOwning(String name, int previousAmount) { String customerOwns = ""; double outstanding = 10 + previousAmount; customerOwns += "****/n"; customerOwns += "**Customer Owns**/n"; customerOwns += "****/n"; for (Order order : orders) { outstanding += order.getAmount(); } customerOwns += "na...
ExtractMethod { public String printOwning(String name, int previousAmount) { String customerOwns = ""; double outstanding = 10 + previousAmount; customerOwns += "****/n"; customerOwns += "**Customer Owns**/n"; customerOwns += "****/n"; for (Order order : orders) { outstanding += order.getAmount(); } customerOwns += "na...
ExtractMethod { public String printOwning(String name, int previousAmount) { String customerOwns = ""; double outstanding = 10 + previousAmount; customerOwns += "****/n"; customerOwns += "**Customer Owns**/n"; customerOwns += "****/n"; for (Order order : orders) { outstanding += order.getAmount(); } customerOwns += "na...
ExtractMethod { public String printOwning(String name, int previousAmount) { String customerOwns = ""; double outstanding = 10 + previousAmount; customerOwns += "****/n"; customerOwns += "**Customer Owns**/n"; customerOwns += "****/n"; for (Order order : orders) { outstanding += order.getAmount(); } customerOwns += "na...
@Test public void should_get_discount_7_given_value_is_over_50_and_quantity_is_over_100_and_yearToEnd_is_over_10000() { RemoveAssignmentsToParameters removeAssignmentsToParameters = new RemoveAssignmentsToParameters(); assertEquals(53, removeAssignmentsToParameters.discount(60, 200, 20000)); }
public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } int discount(int inputVal, int quantity, int yearToDate); }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } int discount(int inputVal, int quantity, int yearToDate); }
@Test public void should_get_discount_5_given_value_is_less_than_50_and_quantity_is_over_100_and_yearToEnd_is_over_10000() { RemoveAssignmentsToParameters removeAssignmentsToParameters = new RemoveAssignmentsToParameters(); assertEquals(35, removeAssignmentsToParameters.discount(40, 200, 20000)); }
public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } int discount(int inputVal, int quantity, int yearToDate); }
RemoveAssignmentsToParameters { public int discount(int inputVal, int quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2; if (quantity > 100) inputVal -= 1; if (yearToDate > 10000) inputVal -= 4; return inputVal; } int discount(int inputVal, int quantity, int yearToDate); }
@Test public void should_get_right_discount_given_base_price_is_over_1000() { ReplaceTempWithQuery replaceTempWithQuery = new ReplaceTempWithQuery(1000, 2); assertEquals(1900, replaceTempWithQuery.getPrice(), 2); }
public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } ReplaceTempWithQuery(double quantity, double itemPrice); }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } ReplaceTempWithQuery(double quantity, double itemPrice); double getPrice(); }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } ReplaceTempWithQuery(double quantity, double itemPrice); double getPrice(); }
@Test public void should_get_right_discount_given_base_price_is_less_than_1000() { ReplaceTempWithQuery replaceTempWithQuery = new ReplaceTempWithQuery(400, 2); assertEquals(784, replaceTempWithQuery.getPrice(), 2); }
public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } ReplaceTempWithQuery(double quantity, double itemPrice); }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } ReplaceTempWithQuery(double quantity, double itemPrice); double getPrice(); }
ReplaceTempWithQuery { public double getPrice() { double basePrice = quantity * itemPrice; double discountFactor; if (basePrice > 1000) discountFactor = 0.95; else discountFactor = 0.98; return basePrice * discountFactor; } ReplaceTempWithQuery(double quantity, double itemPrice); double getPrice(); }
@Test public void should_get_right_gamma_given() { ReplaceMethodWithMethodObject replaceMethodWithMethodObject = new ReplaceMethodWithMethodObject(); int gamma = replaceMethodWithMethodObject.gamma(10, 5, 100); assertEquals(7600, gamma); }
public int gamma(int inputVal, int quantity, int yearToDate) { int importantValue1 = inputVal * quantity; int importantValue2 = inputVal * yearToDate + 100; if ((yearToDate - importantValue1) > 100) importantValue2 -= 20; int importantValue3 = importantValue2 * 7; return importantValue3 - 2 * importantValue1; }
ReplaceMethodWithMethodObject { public int gamma(int inputVal, int quantity, int yearToDate) { int importantValue1 = inputVal * quantity; int importantValue2 = inputVal * yearToDate + 100; if ((yearToDate - importantValue1) > 100) importantValue2 -= 20; int importantValue3 = importantValue2 * 7; return importantValue3 ...
ReplaceMethodWithMethodObject { public int gamma(int inputVal, int quantity, int yearToDate) { int importantValue1 = inputVal * quantity; int importantValue2 = inputVal * yearToDate + 100; if ((yearToDate - importantValue1) > 100) importantValue2 -= 20; int importantValue3 = importantValue2 * 7; return importantValue3 ...
ReplaceMethodWithMethodObject { public int gamma(int inputVal, int quantity, int yearToDate) { int importantValue1 = inputVal * quantity; int importantValue2 = inputVal * yearToDate + 100; if ((yearToDate - importantValue1) > 100) importantValue2 -= 20; int importantValue3 = importantValue2 * 7; return importantValue3 ...
ReplaceMethodWithMethodObject { public int gamma(int inputVal, int quantity, int yearToDate) { int importantValue1 = inputVal * quantity; int importantValue2 = inputVal * yearToDate + 100; if ((yearToDate - importantValue1) > 100) importantValue2 -= 20; int importantValue3 = importantValue2 * 7; return importantValue3 ...