|
| 1 | +/** |
| 2 | + * Copyright 2014 Wordnik, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import com.wordnik.swagger.codegen.Codegen |
| 18 | +import com.wordnik.swagger.codegen.BasicJavaGenerator |
| 19 | +import com.wordnik.swagger.codegen.model._ |
| 20 | + |
| 21 | +import org.junit.runner.RunWith |
| 22 | +import org.scalatest.junit.JUnitRunner |
| 23 | +import org.scalatest.FlatSpec |
| 24 | +import org.scalatest.matchers.ShouldMatchers |
| 25 | + |
| 26 | +import scala.reflect.BeanProperty |
| 27 | + |
| 28 | +@RunWith(classOf[JUnitRunner]) |
| 29 | +class CodegenTest extends FlatSpec with ShouldMatchers { |
| 30 | + |
| 31 | + val subject = new Codegen(new BasicJavaGenerator) |
| 32 | + |
| 33 | + val testOp = new Operation("GET", |
| 34 | + "List All Contacts", |
| 35 | + "", |
| 36 | + "Array[ContactData]", |
| 37 | + "listContacts", |
| 38 | + 0, |
| 39 | + List.empty, |
| 40 | + List.empty, |
| 41 | + List.empty, |
| 42 | + List.empty, |
| 43 | + List.empty, |
| 44 | + List.empty, |
| 45 | + None) |
| 46 | + |
| 47 | + behavior of "Codegen" |
| 48 | + /* |
| 49 | + * A return specified as "Array" should map to "List" |
| 50 | + */ |
| 51 | + it should "recognize the returnContainer as a List" in { |
| 52 | + val map = subject.apiToMap("/contacts", testOp) |
| 53 | + map("returnContainer") should be (Some("List")) |
| 54 | + } |
| 55 | +} |
0 commit comments