use of org.ovirt.api.metamodel.runtime.xml.XmlReader in project ovirt-engine-sdk-java by oVirt.
the class ActionReaderTest method testFaultActionWithReason.
/**
* Checks that having fault action with reason and detail is handled correctly
*/
@Test
public void testFaultActionWithReason() throws Exception {
String response = "<action><fault><reason>myreason</reason><detail>mydetail</detail></fault></action>";
try (InputStream stream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
XmlReader reader = new XmlReader(stream)) {
Action action = XmlActionReader.readOne(reader);
assertTrue(action.faultPresent());
assertTrue(action.fault().reasonPresent());
assertEquals("myreason", action.fault().reason());
assertTrue(action.fault().detailPresent());
assertEquals("mydetail", action.fault().detail());
}
}
use of org.ovirt.api.metamodel.runtime.xml.XmlReader in project ovirt-engine-sdk-java by oVirt.
the class ActionReaderTest method testFaultActionNoValue.
/**
* Checks that having fault action empty is handled correctly
*/
@Test
public void testFaultActionNoValue() throws Exception {
try (InputStream stream = new ByteArrayInputStream("<fault/>".getBytes(StandardCharsets.UTF_8));
XmlReader reader = new XmlReader(stream)) {
Action action = XmlActionReader.readOne(reader);
assertFalse(action.statusPresent());
assertFalse(action.faultPresent());
assertNull(action.fault());
assertNull(action.status());
}
}
use of org.ovirt.api.metamodel.runtime.xml.XmlReader in project ovirt-engine-sdk-java by oVirt.
the class ActionReaderTest method testFaultAndStatusActionW.
/**
* Checks that having fault and status action is handled correctly
*/
@Test
public void testFaultAndStatusActionW() throws Exception {
String response = "<action><status>mystatus</status><fault><reason>myreason</reason></fault></action>";
try (InputStream stream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
XmlReader reader = new XmlReader(stream)) {
Action action = XmlActionReader.readOne(reader);
// Check state:
assertTrue(action.statusPresent());
assertEquals("mystatus", action.status());
// Check reason:
assertTrue(action.faultPresent());
assertTrue(action.fault().reasonPresent());
assertEquals("myreason", action.fault().reason());
}
}
use of org.ovirt.api.metamodel.runtime.xml.XmlReader in project ovirt-engine-sdk-java by oVirt.
the class ActionReaderTest method testActionWithState.
/**
* Checks that having action with state is handled correctly
*/
@Test
public void testActionWithState() throws Exception {
String response = "<action><status>mystatus</status></action>";
try (InputStream stream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
XmlReader reader = new XmlReader(stream)) {
Action action = XmlActionReader.readOne(reader);
assertTrue(action.statusPresent());
assertEquals("mystatus", action.status());
}
}
use of org.ovirt.api.metamodel.runtime.xml.XmlReader in project ovirt-engine-sdk-java by oVirt.
the class ClusterReaderTest method testReadValueAfterEmptyList.
/**
* Test given switch type after empty RNG source both are read correctly.
*/
@Test
public void testReadValueAfterEmptyList() throws Exception {
String response = "<cluster>" + "<required_rng_sources/>" + "<switch_type>legacy</switch_type>" + "</cluster>";
try (InputStream stream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
XmlReader reader = new XmlReader(stream)) {
Cluster cluster = XmlClusterReader.readOne(reader);
assertEquals(Arrays.asList(), cluster.requiredRngSources());
assertEquals(SwitchType.LEGACY, cluster.switchType());
}
}
Aggregations