// Path: java2typescript-jackson/src/main/java/java2typescript/jackson/module/grammar/Module.java
// public class Module {
// 
// 	private String name;
// 
// 	private Map<String, AbstractNamedType> namedTypes = new HashMap<String, AbstractNamedType>();
// 
// 	private Map<String, AbstractType> vars = new HashMap<String, AbstractType>();
// 
// 	public Module() {
// 	}
// 
// 	public Module(String name) {
// 		this.name = name;
// 	}
// 
// 	public Map<String, AbstractNamedType> getNamedTypes() {
// 		return namedTypes;
// 	}
// 
// 	public Map<String, AbstractType> getVars() {
// 		return vars;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void write(Writer writer) throws IOException {
// 		new InternalModuleFormatWriter().write(this, writer);
// 	}
// 
// }
// 
// Path: sample-web-app/src/main/java/com/example/rs/PeopleRestService.java
// @Path("/people")
// public class PeopleRestService {
// 	@Inject
// 	private PeopleService peopleService;
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@GET
// 	public Collection<Person> getPeopleList(@QueryParam("page") @DefaultValue("1") final int page) {
// 		return peopleService.getPeople(page, 5);
// 	}
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@Path("/{email}")
// 	@GET
// 	public Person getPeople(@PathParam("email") final String email) {
// 		return peopleService.getByEmail(email);
// 	}
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@POST
// 	public Response addPerson(@Context final UriInfo uriInfo, @FormParam("email") final String email,
// 			@FormParam("firstName") final String firstName, @FormParam("lastName") final String lastName) {
// 
// 		peopleService.addPerson(email, firstName, lastName);
// 		return Response.created(uriInfo.getRequestUriBuilder().path(email).build()).build();
// 	}
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@Path("/{email}")
// 	@PUT
// 	public Person updatePerson(@PathParam("email") final String email, @FormParam("firstName") final String firstName,
// 			@FormParam("lastName") final String lastName) {
// 
// 		final Person person = peopleService.getByEmail(email);
// 
// 		if (firstName != null) {
// 			person.setFirstName(firstName);
// 		}
// 
// 		if (lastName != null) {
// 			person.setLastName(lastName);
// 		}
// 
// 		return person;
// 	}
// 
// 	@Path("/{email}")
// 	@DELETE
// 	public Response deletePerson(@PathParam("email") final String email) {
// 		peopleService.removePerson(email);
// 		return Response.ok().build();
// 	}
// 
// }


import com.example.rs.PeopleRestService;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Collections;
import java2typescript.jackson.module.grammar.Module;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import org.junit.Before;
import org.junit.Test;
/*******************************************************************************
 * Copyright 2013 Raphael Jolivet
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package java2typescript.jaxrs;





public class DescriptorGeneratorTest {

	private Writer out;

	static class MyObject {
		public String field;
	}

	@Path("/")
	static private interface ExampleService {

		@Path("/{id}")
		@POST
		public String aPostMethod(//
				@QueryParam("q1") String queryParam, //
				@PathParam("id") String id, //
				@FormParam("formParam") Integer formParam, //
				String postPayload);

		@Path("/{id}")
		@GET
		public void aGetMethod(//
				@QueryParam("q1") String queryParam, //
				@PathParam("id") String id, //
				@FormParam("formParam") Integer formParam, //
				MyObject postPayload);

	}

	@Before
	public void setUp() {
		out = new OutputStreamWriter(System.out);
	}

	@Test
	public void testJSGenerate() throws JsonGenerationException, JsonMappingException, IOException {
		ServiceDescriptorGenerator descGen = new ServiceDescriptorGenerator(
// Path: java2typescript-jackson/src/main/java/java2typescript/jackson/module/grammar/Module.java
// public class Module {
// 
// 	private String name;
// 
// 	private Map<String, AbstractNamedType> namedTypes = new HashMap<String, AbstractNamedType>();
// 
// 	private Map<String, AbstractType> vars = new HashMap<String, AbstractType>();
// 
// 	public Module() {
// 	}
// 
// 	public Module(String name) {
// 		this.name = name;
// 	}
// 
// 	public Map<String, AbstractNamedType> getNamedTypes() {
// 		return namedTypes;
// 	}
// 
// 	public Map<String, AbstractType> getVars() {
// 		return vars;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void write(Writer writer) throws IOException {
// 		new InternalModuleFormatWriter().write(this, writer);
// 	}
// 
// }
// 
// Path: sample-web-app/src/main/java/com/example/rs/PeopleRestService.java
// @Path("/people")
// public class PeopleRestService {
// 	@Inject
// 	private PeopleService peopleService;
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@GET
// 	public Collection<Person> getPeopleList(@QueryParam("page") @DefaultValue("1") final int page) {
// 		return peopleService.getPeople(page, 5);
// 	}
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@Path("/{email}")
// 	@GET
// 	public Person getPeople(@PathParam("email") final String email) {
// 		return peopleService.getByEmail(email);
// 	}
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@POST
// 	public Response addPerson(@Context final UriInfo uriInfo, @FormParam("email") final String email,
// 			@FormParam("firstName") final String firstName, @FormParam("lastName") final String lastName) {
// 
// 		peopleService.addPerson(email, firstName, lastName);
// 		return Response.created(uriInfo.getRequestUriBuilder().path(email).build()).build();
// 	}
// 
// 	@Produces({ MediaType.APPLICATION_JSON })
// 	@Path("/{email}")
// 	@PUT
// 	public Person updatePerson(@PathParam("email") final String email, @FormParam("firstName") final String firstName,
// 			@FormParam("lastName") final String lastName) {
// 
// 		final Person person = peopleService.getByEmail(email);
// 
// 		if (firstName != null) {
// 			person.setFirstName(firstName);
// 		}
// 
// 		if (lastName != null) {
// 			person.setLastName(lastName);
// 		}
// 
// 		return person;
// 	}
// 
// 	@Path("/{email}")
// 	@DELETE
// 	public Response deletePerson(@PathParam("email") final String email) {
// 		peopleService.removePerson(email);
// 		return Response.ok().build();
// 	}
// 
// }


// Path: java2typescript-jaxrs/src/test/java/java2typescript/jaxrs/DescriptorGeneratorTest.java
import com.example.rs.PeopleRestService;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Collections;
import java2typescript.jackson.module.grammar.Module;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import org.junit.Before;
import org.junit.Test;

/*******************************************************************************
 * Copyright 2013 Raphael Jolivet
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package java2typescript.jaxrs;





public class DescriptorGeneratorTest {

	private Writer out;

	static class MyObject {
		public String field;
	}

	@Path("/")
	static private interface ExampleService {

		@Path("/{id}")
		@POST
		public String aPostMethod(//
				@QueryParam("q1") String queryParam, //
				@PathParam("id") String id, //
				@FormParam("formParam") Integer formParam, //
				String postPayload);

		@Path("/{id}")
		@GET
		public void aGetMethod(//
				@QueryParam("q1") String queryParam, //
				@PathParam("id") String id, //
				@FormParam("formParam") Integer formParam, //
				MyObject postPayload);

	}

	@Before
	public void setUp() {
		out = new OutputStreamWriter(System.out);
	}

	@Test
	public void testJSGenerate() throws JsonGenerationException, JsonMappingException, IOException {
		ServiceDescriptorGenerator descGen = new ServiceDescriptorGenerator(
				Collections.singletonList(PeopleRestService.class));