isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Gurr <jere...@infusionsoft.com>
Subject Re: infinite loop being hit during isis startup
Date Thu, 12 Sep 2013 20:19:57 GMT
Oscar,

The generic Spec Transformer looks interesting. I couldn't quite figure out how it would be
used. Maybe you could give an example test case?

What I've got working right now can drive tests like the following:

Scenario: A new topping is added
Given these toppings exist:
| topping name    | price |
| Pepperoni       | 1.00  |
| Extra Cheese    | 1.25  |
When new toppings are created:
| topping name    | price |
| Pineapple       | 0.50  |
Then these toppings will remain:
| topping name    | price |
| Pepperoni       | 1.00  |
| Extra Cheese    | 1.25  |
| Pineapple       | 0.50  |

The cool part is that "topping" and "toppings" are parameterized, as well as the field names,
so I can use any domain entity without having to change the glue. It will work with any number
of rows or field names. I suspect this is similar to what you are working on.

Of course this only tests the most basic of features, but I suspect it wouldn't be too hard
to extend this to meet work with many different kinds of entity tests.

My glue code looks like this:

@Given("^these ([\\w ]+) exist:$")
public void initializeEntities(@NotNull String niceServiceName, @NotNull List<Map<String,
String>> entitiesToAdd) throws Throwable {
if (entitiesToAdd.size() > 0) {
final Class<? extends DataEntityService> serviceClass = dataEntityUtil.getDataEntityServiceClass(niceServiceName);
final DataEntityService service = service(serviceClass);
service.clear();
createEntities(niceServiceName, entitiesToAdd);
}
}

@When("^new ([\\w ]+) are created:$")
public void createEntities(@NotNull String niceServiceName, @NotNull List<Map<String,
String>> entitiesToAdd) throws Throwable {
final Class<? extends DataEntityService> serviceClass = dataEntityUtil.getDataEntityServiceClass(niceServiceName);
final DataEntityService service = service(serviceClass);
for (Map<String, String> entityMap : entitiesToAdd) {
final DataEntity entity = dataEntityUtil.convertToEntity(service, entityMap);
service.makePersistent(entity);
}
}

@Then("^these ([\\w ]+) will remain:$")
public void assertEntitiesExist(@NotNull String niceServiceName, @NotNull List<Map<String,
String>> entitiesWillExist) throws Throwable {
final Class<? extends DataEntityService> serviceClass = dataEntityUtil.getDataEntityServiceClass(niceServiceName);
final DataEntityService service = service(serviceClass);

for (Map<String, String> entityMap : entitiesWillExist) {
Assert.assertTrue("Entity doesn't exist", dataEntityUtil.entityExists(service, entityMap));
}
}

I am still quite new to ISIS and Cucumber, so any advice on how this can be improved is more
than welcome.

-- Jeremy

On Sep 12, 2013, at 11:23 AM, GESCONSULTOR - Óscar Bou wrote:


Same happened to a mate upgrading to the latest snapshot.

A default value as suggested by Jeremy would be ok.

Jeremy, did you see the mail at [1] ?

It's intent was to solve your idea of a "generic" Spec Transformer for Isis entities. There
I copied the code of a generic class.
I'm testing an improved version  and plan to commit it next week (in fact, 1 abstract class
with 2 specializations; one allowing null entities, and one throwing an exception if the referenced
object is not found - as normally is a "transcription" problem).

If you want to previously access it, don't hesitate to ask and I can attach current version
to a JIRA ticket.

HTH,

Oscar




[1] http://markmail.org/search/isis-users+list:org.apache.incubator.isis-users#query:isis-users%20list%3Aorg.apache.incubator.isis-users%20from%3A%22GESCONSULTOR%20-%20%C3%93scar%20Bou%22+page:9+mid:tibcgc45fii566w3+state:results



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message