@Test
public void writeConfigOrderIsPreservedMulticlass() throws Exception {

  @Api(name = "onetoday", description = "OneToday API")
  final class OneToday {
  }
  @Api(name = "onetoday", description = "OneToday API")
  final class OneToday2 {
  }
  @Api(name = "onetodayadmin", description = "One Today Admin API")
  final class OneTodayAdmin {
  }
  @Api(name = "onetodayadmin", description = "One Today Admin API")
  final class OneTodayAdmin2 {
  }
  ApiConfigValidator validator = Mockito.mock(ApiConfigValidator.class);
  TypeLoader typeLoader = new TypeLoader();
  JsonConfigWriter writer =
      new JsonConfigWriter(new TypeLoader(JsonConfigWriter.class.getClassLoader()), validator);
  ApiConfig oneToday = new ApiConfig.Factory().create(serviceContext, typeLoader, OneToday.class);
  ApiConfig oneToday2 =
      new ApiConfig.Factory().create(serviceContext, typeLoader, OneToday2.class);
  ApiConfig oneTodayAdmin =
      new ApiConfig.Factory().create(serviceContext, typeLoader, OneTodayAdmin.class);
  ApiConfig oneTodayAdmin2 =
      new ApiConfig.Factory().create(serviceContext, typeLoader, OneTodayAdmin2.class);
  oneToday.setName("onetoday");
  oneToday.setVersion("v1");
  oneToday2.setName("onetoday");
  oneToday2.setVersion("v1");
  oneTodayAdmin.setName("onetodayadmin");
  oneTodayAdmin.setVersion("v1");
  oneTodayAdmin2.setName("onetodayadmin");
  oneTodayAdmin2.setVersion("v1");
  Map<ApiKey, String> configs =
      writer.writeConfig(Lists.newArrayList(oneToday, oneTodayAdmin, oneTodayAdmin2, oneToday2));
  Iterator<ApiKey> iterator = configs.keySet().iterator();
  assertEquals(new ApiKey("onetoday", "v1", "https://myapp.appspot.com/_ah/api"),
      iterator.next());
  assertEquals(new ApiKey("onetodayadmin", "v1", "https://myapp.appspot.com/_ah/api"),
      iterator.next());
}