Skip to content

Commit

Permalink
add temperatureUnits enum (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferozco authored Jul 30, 2018
1 parent 48c7b04 commit 3cff747
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
7 changes: 6 additions & 1 deletion recipe-example-api/src/main/conjure/recipe-example-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ types:
Temperature:
fields:
degree: double
unit: string
unit: TemperatureUnit

Ingredient:
alias: string
Expand All @@ -29,6 +29,11 @@ types:
name: RecipeName
steps: list<RecipeStep>

TemperatureUnit:
values:
- FAHRENHEIT
- CELCIUS

errors:
RecipeNotFound:
namespace: Recipe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Resources;
import com.palantir.conjure.examples.recipe.api.BakeStep;
import com.palantir.conjure.examples.recipe.api.Ingredient;
import com.palantir.conjure.examples.recipe.api.Recipe;
import com.palantir.conjure.examples.recipe.api.RecipeBookService;
import com.palantir.conjure.examples.recipe.api.RecipeName;
import com.palantir.conjure.examples.recipe.api.RecipeStep;
import com.palantir.conjure.examples.recipe.api.Temperature;
import com.palantir.conjure.examples.recipe.api.TemperatureUnit;
import feign.Client;
import feign.Feign;
import feign.FeignException;
Expand Down Expand Up @@ -72,4 +79,22 @@ public void getRecipe() {
Set<Recipe> recipes = client.getAllRecipes();
assertEquals(RULE.getConfiguration().getRecipes(), recipes);
}

@Test
public void getRecipeWithBake() {
RecipeName recipeName = RecipeName.of("baked potatoes");
Recipe recipe = client.getRecipe(recipeName);
Recipe expectedRecipe = Recipe.of(recipeName, ImmutableList.of(
RecipeStep.mix(ImmutableSet.of(
Ingredient.of("rub oil all over the potatoes"),
Ingredient.of("Rub salt all over the potatoes"))),
RecipeStep.bake(BakeStep.builder()
.temperature(Temperature.builder()
.degree(220)
.unit(TemperatureUnit.CELCIUS)
.build())
.durationInSeconds(2700)
.build())));
assertEquals(expectedRecipe, recipe);
}
}
4 changes: 2 additions & 2 deletions recipe-example-server/src/test/resources/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ recipes:
bake:
temperature:
degree: 230
unit: "C"
unit: "CELCIUS"
durationInSeconds: 1200
- name: "baked potatoes"
steps:
Expand All @@ -25,5 +25,5 @@ recipes:
bake:
temperature:
degree: 220
unit: "C"
unit: "CELCIUS"
durationInSeconds: 2700
6 changes: 3 additions & 3 deletions recipe-example-server/var/conf/recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ recipes:
bake:
temperature:
degree: 230
unit: "C"
unit: "FAHRENHEIT"
durationInSeconds: 1200
- name: "roasted broccoli with garlic"
steps:
Expand All @@ -32,7 +32,7 @@ recipes:
bake:
temperature:
degree: 230
unit: "C"
unit: "CELCIUS"
durationInSeconds: 1200
- name: "baked potatoes"
steps:
Expand All @@ -42,6 +42,6 @@ recipes:
bake:
temperature:
degree: 220
unit: "C"
unit: "CELCIUS"
durationInSeconds: 2700

0 comments on commit 3cff747

Please sign in to comment.