Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Upgrades ScalaTest assertions #302

Merged
merged 1 commit into from
Feb 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .atomist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ editor:
- "rug_archive_name": "rug"
- "rug_archive_group_id": "atomist"

---
kind: "operation"
client: "rug-cli 0.23.0-SNAPSHOT"
executor:
name: "UpgradeScalaTestAssertions"
group: "atomist-rugs"
artifact: "scala-editors"
version: "0.1.0"
origin:
repo: "n/a"
branch: "n/a"
sha: "n/a"

Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ class HandlerArchiveReaderTest extends FlatSpec with Matchers {
val har = new HandlerArchiveReader(treeMaterializer, atomistConfig)
val handlers = har.handlers("XX", TypeScriptBuilder.compileWithModel(new SimpleFileBasedArtifactSource("", FirstHandler)), None, Nil,
new ConsoleMessageBuilder("XX", null))
handlers.size should be(1)
handlers.head.rootNodeName should be("issue")
assert(handlers.size === 1)
assert(handlers.head.rootNodeName === "issue")
}

it should "parse two handlers" in {
val har = new HandlerArchiveReader(treeMaterializer, atomistConfig)
val handlers = har.handlers("XX", TypeScriptBuilder.compileWithModel(new SimpleFileBasedArtifactSource("", Seq(FirstHandler, SecondHandler))), None, Nil,
new ConsoleMessageBuilder("XX", null))
handlers.size should be(2)
assert(handlers.size === 2)
handlers.exists(h => h.rootNodeName == "issue") should be(true)
handlers.exists(h => h.rootNodeName == "commit") should be(true)
}
Expand All @@ -76,16 +76,16 @@ class HandlerArchiveReaderTest extends FlatSpec with Matchers {
val har = new HandlerArchiveReader(treeMaterializer, atomistConfig)
val handlers = har.handlers("XX", TypeScriptBuilder.compileWithModel(SimpleFileBasedArtifactSource(NamedJavaScriptEventHandlerTest.reOpenCloseIssueProgram,NamedJavaScriptEventHandlerTest.issuesStuff)), None, Nil,
new ConsoleMessageBuilder("XX", null))
handlers.size should be(1)
handlers.head.rootNodeName should be("issue")
assert(handlers.size === 1)
assert(handlers.head.rootNodeName === "issue")
}

it should "allow a correlationId to be set" in {
val har = new HandlerArchiveReader(treeMaterializer, atomistConfig)
val messageBuilder = new ConsoleMessageBuilder("XX", null)
val handlers = har.handlers("XX", TypeScriptBuilder.compileWithModel(new SimpleFileBasedArtifactSource("", ThirdHandler)), None, Nil, messageBuilder)
handlers.size should be(1)
handlers.head.rootNodeName should be("commit")
assert(handlers.size === 1)
assert(handlers.head.rootNodeName === "commit")
}

object TestTreeMaterializer extends TreeMaterializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ class ProjectOperationInfoTest extends FlatSpec with Matchers {

it should "not create default gav appropriately without group" in {
val poi = SimpleProjectOperationInfo("name", "desc", Some("group"), None, Nil, Nil)
poi.gav.isPresent should be(false)
assert(poi.gav.isPresent === false)
}

it should "not create default gav appropriately without version" in {
val poi = SimpleProjectOperationInfo("name", "desc", None, Some("version"), Nil, Nil)
poi.gav.isPresent should be(false)
assert(poi.gav.isPresent === false)
}

it should "create correct gav with group and version" in {
val (group, version) = ("group", "version")
val poi = SimpleProjectOperationInfo("name", "desc", Some(group), Some(version), Nil, Nil)
poi.gav.isPresent should be(true)
poi.gav.get should equal(SimpleResourceSpecifier(group, poi.name, version))
assert(poi.gav.isPresent === true)
assert(poi.gav.get === SimpleResourceSpecifier(group, poi.name, version))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,34 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
it should "parse single editor" in {
val apc = new ProjectOperationArchiveReader(atomistConfig)
val ops = apc.findOperations(new SimpleFileBasedArtifactSource("", FirstEditor), None, Nil)
ops.editors.size should be(1)
ops.editorNames should equal(Seq("First"))
ops.reviewers should equal(Nil)
ops.reviewerNames should equal(Nil)
ops.generators should equal(Nil)
ops.generatorNames should equal(Nil)
assert(ops.editors.size === 1)
assert(ops.editorNames === Seq("First"))
assert(ops.reviewers === Nil)
assert(ops.reviewerNames === Nil)
assert(ops.generators === Nil)
assert(ops.generatorNames === Nil)
}

it should "parse editor and reviewer" in {
val apc = new ProjectOperationArchiveReader(atomistConfig)
val ops = apc.findOperations(new SimpleFileBasedArtifactSource("", Seq(FirstEditor, SecondOp)), None, Nil)
ops.editors.size should be(1)
ops.editorNames should equal(Seq("First"))
ops.reviewers.size should be(1)
ops.reviewerNames should equal(Seq("Second"))
ops.generators should equal(Nil)
ops.generatorNames should equal(Nil)
assert(ops.editors.size === 1)
assert(ops.editorNames === Seq("First"))
assert(ops.reviewers.size === 1)
assert(ops.reviewerNames === Seq("Second"))
assert(ops.generators === Nil)
assert(ops.generatorNames === Nil)
}

it should "parse editor and reviewer and generator" in {
val apc = new ProjectOperationArchiveReader(atomistConfig)
val ops = apc.findOperations(new SimpleFileBasedArtifactSource("", Seq(FirstEditor, SecondOp, Generator)), None, Nil)
ops.editors.size should be(1)
ops.editorNames.toSet should equal(Set("First"))
ops.reviewers.size should be(1)
ops.reviewerNames should equal(Seq("Second"))
ops.generators.size should equal(1)
ops.generatorNames should equal(Seq("Published"))
assert(ops.editors.size === 1)
assert(ops.editorNames.toSet === Set("First"))
assert(ops.reviewers.size === 1)
assert(ops.reviewerNames === Seq("Second"))
assert(ops.generators.size === 1)
assert(ops.generatorNames === Seq("Published"))
}

it should "find imports in a project that uses them" in {
Expand All @@ -106,8 +106,8 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
StringFileArtifact(".atomist/editors/SimpleEditor.ts", TypeScriptRugEditorTest.SimpleEditorTaggedAndMeta)
))
val ops = apc.findOperations(as, None, Nil)
ops.editors.size should be(1)
ops.editors.head.parameters.size should be(2)
assert(ops.editors.size === 1)
assert(ops.editors.head.parameters.size === 2)
}

val SimpleExecutor =
Expand Down Expand Up @@ -135,8 +135,8 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
StringFileArtifact(".atomist/executors/SimpleExecutor.ts", SimpleExecutor)
))
val ops = apc.findOperations(as, None, Nil)
ops.executors.size should be(1)
ops.executors.head.parameters.size should be(0)
assert(ops.executors.size === 1)
assert(ops.executors.head.parameters.size === 0)
val s2 = new FakeServiceSource(Nil)
ops.executors.head.execute(s2, SimpleProjectOperationArguments.Empty)
}
Expand All @@ -152,12 +152,12 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
f2
))
val ops = apc.findOperations(rugAs, None, Nil)
ops.generators.size should be(1)
ops.generators.head.parameters.size should be(0)
assert(ops.generators.size === 1)
assert(ops.generators.head.parameters.size === 0)
val result = ops.generators.head.generate("woot",
SimpleProjectOperationArguments("", Map("content" -> "woot")))
// Should preserve content from the backing archive
result.id.name should be("woot")
assert(result.id.name === "woot")
result.findFile(f1.path).get.content.equals(f1.content) should be(true)
result.findFile(f2.path).get.content.equals(f2.content) should be(true)

Expand All @@ -180,8 +180,8 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
) + TypeScriptBuilder.userModel

val ops = apc.findOperations(rugAs, None, Nil)
ops.editors.size should be(1)
ops.editors.head.parameters.size should be(1)
assert(ops.editors.size === 1)
assert(ops.editors.head.parameters.size === 1)
}

it should "ignore unbound handler" in {
Expand Down Expand Up @@ -213,8 +213,8 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
StringFileArtifact(".atomist/handlers/sub.ts", handler)
))
val ops = apc.findOperations(rugAs, None, Nil)
ops.generators.size should be(1)
ops.generators.head.parameters.size should be(0)
assert(ops.generators.size === 1)
assert(ops.generators.head.parameters.size === 0)
val result = ops.generators.head.generate("woot",
SimpleProjectOperationArguments("", Map("content" -> "woot")))
// Should preserve content from the backing archive
Expand All @@ -239,8 +239,8 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
NamedJavaScriptEventHandlerTest.issuesStuff
))
val ops = apc.findOperations(rugAs, None, Nil)
ops.generators.size should be(1)
ops.generators.head.parameters.size should be(0)
assert(ops.generators.size === 1)
assert(ops.generators.head.parameters.size === 0)
val result = ops.generators.head.generate("woot", SimpleProjectOperationArguments("", Map("content" -> "woot")))
// Should preserve content from the backing archive
result.findFile(f1.path).get.content.equals(f1.content) should be(true)
Expand All @@ -256,14 +256,17 @@ class FakeServiceSource(val projects: Seq[ArtifactSource]) extends ServiceSource

val updatePersister = new FakeUpdatePersister


val teamId = "atomist-test"

override def pathExpressionEngine: jsPathExpressionEngine =
new jsPathExpressionEngine(teamContext = this)


override def messageBuilder: MessageBuilder =
new ConsoleMessageBuilder(teamId, EmptyActionRegistry)


var issues = ListBuffer.empty[Issue]

override def services: Seq[Service] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,35 @@ class MustacheMergeToolTest extends FlatSpec with Matchers {
it should "process template files" in {
val mmt = new MustacheMergeTool(templateAs)
val files = mmt.processTemplateFiles(FirstContext, templateAs.allFiles)
files.size should equal(3)
assert(files.size === 3)
val expectedPath = "location_was_true.txt"
// First.mustache
files.map(f => f.path).toSet should equal(Set(static1.path, expectedPath, "first.mustache"))
files.find(_.path.equals(expectedPath)).get.content should equal(FirstExpected)
assert(files.map(f => f.path).toSet === Set(static1.path, expectedPath, "first.mustache"))
assert(files.find(_.path.equals(expectedPath)).get.content === FirstExpected)
}

it should "process classpath template files" in {
val mmt = new MustacheMergeTool(cpTemplateAs)
val files = mmt.processTemplateFiles(FirstContext, cpTemplateAs.allFiles)
files.size should equal(1)
assert(files.size === 1)
val expectedPath = "G'day Chris. You just scored 10000 dollars. But the ATO has hit you with tax so you'll only get 6000.0"
files.map(f => f.path).toSet should equal(Set("test.mustache"))
files.head.content should equal(expectedPath)
assert(files.map(f => f.path).toSet === Set("test.mustache"))
assert(files.head.content === expectedPath)
}

it should "process template ArtifactSource" in {
val mmt = new MustacheMergeTool(templateAs)
val files = mmt.processTemplateFiles(FirstContext, templateAs).allFiles
files.size should equal(3)
assert(files.size === 3)
val expectedPath = "location_was_true.txt"
// First.mustache
files.map(f => f.path).toSet should equal(Set(static1.path, expectedPath, "first.mustache"))
files.find(_.path.equals(expectedPath)).get.content should equal(FirstExpected)
assert(files.map(f => f.path).toSet === Set(static1.path, expectedPath, "first.mustache"))
assert(files.find(_.path.equals(expectedPath)).get.content === FirstExpected)
}

val mt = new MustacheMergeTool(new EmptyArtifactSource(""))


it should "strip .mustache extension" in {
val name = "template_.mustache"
mt.toInPlaceFilePath(name) should equal ("template")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,42 +132,42 @@ class YmlProjectOperationInfoParserTest extends FlatSpec with Matchers {

it should "return empty parameters if no parameters specified" in {
val poi = YmlProjectOperationInfoParser.parse(noParameters)
poi.parameters.isEmpty should be(true)
assert(poi.parameters.isEmpty === true)
}

it should "return empty tags if no tags specified" in {
val poi = YmlProjectOperationInfoParser.parse(noParameters)
poi.tags.isEmpty should be(true)
assert(poi.tags.isEmpty === true)
}

it should "return no GAV if version and group not specified" in {
val poi = YmlProjectOperationInfoParser.parse(noParameters)
poi.gav.isDefined should be(false)
assert(poi.gav.isDefined === false)
}

it should "return GAV if version and group specified" in {
val poi = YmlProjectOperationInfoParser.parse(valid1)
poi.gav.isDefined should be(true)
poi.gav.get should equal(SimpleResourceSpecifier("atomist", "test1", "1.0"))
assert(poi.gav.isDefined === true)
assert(poi.gav.get === SimpleResourceSpecifier("atomist", "test1", "1.0"))
}

it should "find name in valid content" in {
val poi = YmlProjectOperationInfoParser.parse(valid1)
poi.name should equal("test1")
poi.description should equal("descr1")
poi.parameters.size should equal(2)
assert(poi.name === "test1")
assert(poi.description === "descr1")
assert(poi.parameters.size === 2)
}

it should "find parameters in valid content using default values" in {
val poi = YmlProjectOperationInfoParser.parse(valid1)
poi.name should equal("test1")
poi.description should equal("descr1")
poi.parameters.size should equal(2)
poi.parameters(0).getName should equal("foo")
poi.parameters(0).isRequired should equal(true)
poi.parameters(1).getName should equal("bar")
poi.parameters(1).isRequired should equal(false)
poi.parameters(1).getPattern should equal(ParameterValidationPatterns.MatchAny)
assert(poi.name === "test1")
assert(poi.description === "descr1")
assert(poi.parameters.size === 2)
assert(poi.parameters(0).getName === "foo")
assert(poi.parameters(0).isRequired === true)
assert(poi.parameters(1).getName === "bar")
assert(poi.parameters(1).isRequired === false)
assert(poi.parameters(1).getPattern === ParameterValidationPatterns.MatchAny)
}

it should "honor parameter overrides without strange characters" in {
Expand All @@ -180,25 +180,25 @@ class YmlProjectOperationInfoParserTest extends FlatSpec with Matchers {

it should "respect tags" in {
val poi = checkWithOverrides("name1", "description is good", required = true, ".+", "default_val", "You should've input something")
poi.tags.size should equal(2)
poi.tags(0).name should equal("spring")
poi.tags(0).description should equal("Spring Framework")
poi.tags(1).name should equal("spring-boot")
poi.tags(1).description should equal("Spring Boot")
assert(poi.tags.size === 2)
assert(poi.tags(0).name === "spring")
assert(poi.tags(0).description === "Spring Framework")
assert(poi.tags(1).name === "spring-boot")
assert(poi.tags(1).description === "Spring Boot")
}

it should "accept multiline description" is pending

private def checkWithOverrides(name: String, description: String, required: Boolean, pattern: String, default: String, validInputDescription: String) = {
private def checkWithOverrides(name: String, description: String, required: Boolean, pattern: String, default: String, validInputDescription: String) = {
val yml = withOverrides(name, description, required, pattern, default, validInputDescription)
val poi = YmlProjectOperationInfoParser.parse(yml)
val p = poi.parameters.head
p.getName should equal(name)
p.getDescription should equal(description)
p.isRequired should equal(required)
p.getPattern should equal(pattern)
p.getDefaultValue should equal(default)
p.getValidInputDescription should equal(validInputDescription)
assert(p.getName === name)
assert(p.getDescription === description)
assert(p.isRequired === required)
assert(p.getPattern === pattern)
assert(p.getDefaultValue === default)
assert(p.getValidInputDescription === validInputDescription)
poi
}

Expand All @@ -224,6 +224,6 @@ class YmlProjectOperationInfoParserTest extends FlatSpec with Matchers {
| valid_input_description: A name for this service
""".stripMargin
val parsed = YmlProjectOperationInfoParser.parse(yml)
parsed.parameters.head.getPattern should equal("""[a-zA-Z_$][a-zA-Z\d_$]*""")
assert(parsed.parameters.head.getPattern === """[a-zA-Z_$][a-zA-Z\d_$]*""")
}
}
Loading