@SuppressWarnings("rawtypes")
@Test
public void testOneStepAtTheTimeOrderingOfCalls() {
StringBuilder stringBuilder = new StringBuilder();
JSONFormatter jsonFormatter = new JSONPrettyFormatter(stringBuilder);
Feature feature = feature("Test Feature");
Scenario scenario = scenario("Test Scenario");
Step step1 = step("Given", "Step 1");
Step step2 = step("Given", "Step 2");
final byte[] data1 = new byte[] {1, 2, 3};
String text1 = "text1";
String text2 = "text2";
final byte[] data2 = new byte[] {4};
Result step1Result = result("passed");
Result step2Result = result("failed");
jsonFormatter.uri(uri());
jsonFormatter.feature(feature);
jsonFormatter.startOfScenarioLifeCycle(scenario);
jsonFormatter.before(match(), result("passed"));
jsonFormatter.scenario(scenario);
jsonFormatter.step(step1);
jsonFormatter.match(match());
jsonFormatter.embedding("mime-type", data1);
jsonFormatter.write(text1);
jsonFormatter.result(step1Result);
jsonFormatter.step(step2);
jsonFormatter.match(match());
jsonFormatter.write(text2);
jsonFormatter.embedding("mime-type-2", data2);
jsonFormatter.result(step2Result);
jsonFormatter.endOfScenarioLifeCycle(scenario);
jsonFormatter.eof();
jsonFormatter.done();
jsonFormatter.close();
Gson gson = new Gson();
List result = gson.fromJson(stringBuilder.toString(), List.class);
Map featureJson = (Map) result.get(0);
assertEquals(feature.getName(), featureJson.get("name"));
Map scenarioJson = (Map) ((List) featureJson.get("elements")).get(0);
assertEquals(scenario.getName(), scenarioJson.get("name"));
Map step1Json = (Map) ((List)scenarioJson.get("steps")).get(0);