Skip to content

Commit

Permalink
remove TODO and add preconditons to deleteRecipe
Browse files Browse the repository at this point in the history
  • Loading branch information
qinfchen committed Jul 20, 2018
1 parent 0803557 commit 09af6e4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- deploy:
command: |
if [[ "${CIRCLE_BRANCH}" == "develop" || "${CIRCLE_TAG}" =~ [0-9]+(\.[0-9]+)+(-[a-zA-Z]+[0-9]*)* ]]; then
if [[ "${CIRCLE_TAG}" =~ [0-9]+(\.[0-9]+)+(-[a-zA-Z]+[0-9]*)* ]]; then
./gradlew --stacktrace --continue publish
fi
Expand Down
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ allprojects {
apply plugin: 'nebula.dependency-recommender'

group 'com.palantir.conjure.examples'
// TODO: clarify error message
// workaround for compileConjureTypescript Error: Expected version to be valid SLS version but found "b02eaaf.dirty"
version "0.1.0"
version gitVersion()

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ public RecipeBookResource(Set<Recipe> recipes) {
@Override
public Recipe getRecipe(RecipeName name) {
Preconditions.checkNotNull(name, "Recipe name must be provided.");
Recipe maybeRecipe = this.recipes.get(name);
if (maybeRecipe == null) {
throw RecipeErrors.recipeNotFound(name);
}
return maybeRecipe;
checkIfRecipeExists(name);

return recipes.get(name);
}

@Override
Expand All @@ -58,6 +56,13 @@ public Set<Recipe> getAllRecipes() {

@Override
public void deleteRecipe(RecipeName name) {
checkIfRecipeExists(name);
recipes.remove(name);
}

private void checkIfRecipeExists(RecipeName name) {
if (!this.recipes.containsKey(name)) {
throw RecipeErrors.recipeNotFound(name);
}
}
}

0 comments on commit 09af6e4

Please sign in to comment.