use of org.btrplace.model.constraint.Seq in project scheduler by btrplace.
the class SeqConverter method fromJSON.
@Override
public Seq fromJSON(Model mo, JSONObject o) throws JSONConverterException {
checkId(o);
List<VM> s = new ArrayList<>();
for (Object ob : (JSONArray) o.get("vms")) {
s.add(getVM(mo, (Integer) ob));
}
return new Seq(s);
}
use of org.btrplace.model.constraint.Seq in project scheduler by btrplace.
the class SeqConverterTest method testViables.
@Test
public void testViables() throws JSONConverterException {
Model mo = new DefaultModel();
ConstraintsConverter conv = new ConstraintsConverter();
conv.register(new SeqConverter());
Seq d = new Seq(Arrays.asList(mo.newVM(), mo.newVM(), mo.newVM()));
Seq c = new Seq(Arrays.asList(mo.newVM(), mo.newVM(), mo.newVM()));
Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(d)), d);
Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(c)), c);
System.out.println(conv.toJSON(d));
}
use of org.btrplace.model.constraint.Seq in project scheduler by btrplace.
the class SeqBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodseqs")
public void testGoodSignatures(String str, int nbVMs) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Seq x = (Seq) b.build("namespace test; VM[1..10] : tiny;\n" + str).getConstraints().iterator().next();
Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
Assert.assertEquals(x.isContinuous(), true);
}
Aggregations