{"id":17197689,"url":"https://github.com/dmcg/nowthen","last_synced_at":"2025-09-04T19:13:36.629Z","repository":{"id":14528936,"uuid":"17243397","full_name":"dmcg/nowthen","owner":"dmcg","description":null,"archived":false,"fork":false,"pushed_at":"2015-01-01T21:43:11.000Z","size":160,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T08:36:55.215Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmcg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-27T09:24:33.000Z","updated_at":"2015-01-01T21:43:11.000Z","dependencies_parsed_at":"2022-09-19T13:41:35.993Z","dependency_job_id":null,"html_url":"https://github.com/dmcg/nowthen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dmcg/nowthen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmcg%2Fnowthen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmcg%2Fnowthen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmcg%2Fnowthen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmcg%2Fnowthen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmcg","download_url":"https://codeload.github.com/dmcg/nowthen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmcg%2Fnowthen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273658103,"owners_count":25145219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T01:57:05.521Z","updated_at":"2025-09-04T19:13:31.606Z","avatar_url":"https://github.com/dmcg.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Now Then, Then Now, Now Then, Then, Then, Then Now\n==================================================\n\nNow then, what's all the fuss about?\n\nOne of the conceptual hurdles with JMock is that you have to specify the things that you expect before the actions that provoke your expected outcome.\n\n```java\nmockery.expecting(new ExpectationBuilder() {{\n  oneOf(missile).launch();\n}});\n\nbutton.press();\n```\n\nI've been experimenting with a new formula\n\n```java\nmockery.when(new Runnable() {\n  public void run() {\n      button.press();\n  }\n}).\nthen(new Expectations() {{\n  oneOf(missile).launch();\n}});\n```\n\nI'm really liking it. I think that the runnable block will play nicely with Java 8 lambda's so reducing the boilerplate. As it is IntelliJ renders as if the lamba was there\n\n```java\nmockery.when(() -\u003e { button.press(); }).\nthen(new Expectations() {{\n  oneOf(missile).launch();\n}});\n```\n\nThe trailing dot before the then is a little odd, but seems entirely in keeping with JMock's usual punctuation abuse.\n\nActually, now that I think of it, the ordering explains why I kept writing helper methods on subclasses named given..(), so I'd have code  like\n\n```java\nmockery.expect(new MyExpections()\n{{\n  givenTurned(key1, true);\n  givenTurned(key2, true);\n  oneOf(missile).launch();\n}});\n\nbutton.press();\n```\n\nSo let's add given(expectations) to mockery to allow this case -\n\n```java\nmockery.given(new MyExpectations()\n{{\n  isTurned(key1, true);\n  isTurned(key2, true);\n}}.\nwhen(() -\u003e { button.press(); }).\nthen(new Expectations()\n{{\n  oneOf(missile).launch();\n}});\n\nmockery.given(new MyExpectations()\n{{\n  isTurned(key1, true);\n  isTurned(key2, false);\n}}.\nwhen(() -\u003e { button.press(); }).\nthen(new Expectations()\n{{\n  never(missile).launch();\n}});\n\n```\n\nFeedback? Should we add this to Mockery?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmcg%2Fnowthen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmcg%2Fnowthen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmcg%2Fnowthen/lists"}