-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
stormcat24
committed
Feb 21, 2015
1 parent
3b2b1d2
commit 4b4b183
Showing
8 changed files
with
115 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
aeromock-cli/src/main/scala/jp/co/cyberagent/aeromock/cli/job/ValidationJob.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package jp.co.cyberagent.aeromock.cli.job | ||
|
||
import java.nio.file.Files | ||
|
||
import jp.co.cyberagent.aeromock.AeromockBadUsingException | ||
import jp.co.cyberagent.aeromock.cli.option.JobOperation | ||
import jp.co.cyberagent.aeromock.cli.validation.TemplateValidator | ||
import jp.co.cyberagent.aeromock.cli.{CliJob, Job} | ||
import jp.co.cyberagent.aeromock.config.Project | ||
import jp.co.cyberagent.aeromock.template.TemplateService | ||
import scaldi.Injector | ||
|
||
import scala.reflect.io.Directory | ||
import scalaz._ | ||
import Scalaz._ | ||
|
||
/** | ||
* Job to check templates and data. | ||
* @author stormcat24 | ||
* @param command [[jp.co.cyberagent.aeromock.cli.option.JobOperation]] | ||
*/ | ||
@Job(name = "test", description = "Execute view test.") | ||
class ValidationJob(override val command: JobOperation)(implicit inj: Injector) extends CliJob { | ||
|
||
val project = inject[Project] | ||
|
||
// templateとデータのセット | ||
val reportRoot = project._test.reportRoot | ||
|
||
// prepare directory | ||
val dir = Directory.apply(scala.reflect.io.Path.apply(reportRoot.toFile)) | ||
dir.deleteRecursively() | ||
Files.createDirectories(reportRoot) | ||
|
||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
override def execute(): Int = { | ||
|
||
(project.template, project.data) match { | ||
case (Success(Some(template)), Success(Some(data))) => // OK | ||
// templateとdataを操作してリクエストをつくる | ||
new TemplateValidator().validate(template, data) | ||
// テンプレをループ | ||
// 紐づくデータを探す。あればリクエスト、なければ警告 | ||
case (Success(_), Success(_)) => // nothing to do | ||
case (_, _) => // TODO error | ||
} | ||
|
||
project.ajax match { | ||
case Success(Some(ajax)) => | ||
case Success(_) => // nothing to do | ||
case f @ Failure(_) => // TODO error | ||
} | ||
|
||
project.messagepack match { | ||
case Success(Some(messagepack)) => | ||
case Success(_) => // nothing to do | ||
case f @ Failure(_) => // TODO error | ||
} | ||
|
||
(project.protobuf, project.data) match { | ||
case (Success(Some(protobuf)), Success(Some(data))) => // OK | ||
case (Success(_), Success(_)) => // nothing to do | ||
case (_, _) => // TODO error | ||
} | ||
|
||
// TODO テスト設定 | ||
// TODO useragent | ||
0 | ||
} | ||
|
||
} |
50 changes: 0 additions & 50 deletions
50
aeromock-cli/src/main/scala/jp/co/cyberagent/aeromock/cli/job/ViewCheckJob.scala
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
aeromock-cli/src/main/scala/jp/co/cyberagent/aeromock/cli/validation/TemplateValidator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package jp.co.cyberagent.aeromock.cli.validation | ||
|
||
import jp.co.cyberagent.aeromock.config.{Data, Template} | ||
import jp.co.cyberagent.aeromock.helper._ | ||
import jp.co.cyberagent.aeromock.template.TemplateService | ||
import scaldi.{Injector, Injectable} | ||
|
||
/** | ||
* | ||
* @author stormcat24 | ||
*/ | ||
class TemplateValidator(implicit inj: Injector) extends AnyRef with Injectable { | ||
|
||
def validate(template: Template, data: Data): Unit = { | ||
|
||
// TODO 拡張子取るためだけに取るのイケてない | ||
val templateService = inject[Option[TemplateService]].get | ||
|
||
template.contexts.map { context => | ||
val contextRoot = s"http://${context.domain}:${context.port}" | ||
|
||
// TODO 拡張子フィルタリング | ||
context.root.filterChildren(s".${templateService.extension}$$").map { templatePath => | ||
println(templatePath) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
aeromock-server/src/main/scala/jp/co/cyberagent/aeromock/template/TemplateContexts.scala
This file was deleted.
Oops, something went wrong.