blob: a93e26a5414b9e59794e040b565e0d27c122d4ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package org.openslx.runvirt.plugin.qemu.configuration;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.math.BigInteger;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.openslx.libvirt.domain.Domain;
import org.openslx.libvirt.domain.DomainUtils;
import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
import org.openslx.virtualization.configuration.transformation.TransformationException;
public class TransformationGenericMemoryTest
{
@Test
@DisplayName( "Test transformation of VM memory configuration" )
public void testTransformationGenericMemory() throws TransformationException
{
final TransformationGenericMemory transformation = new TransformationGenericMemory();
final Domain config = TransformationTestUtils.getDefaultDomain();
final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
final BigInteger defaultMemory = DomainUtils.decodeMemory( TransformationTestUtils.DEFAULT_VM_MEM, "MiB" );
assertNotEquals( defaultMemory.toString(), config.getMemory().toString() );
assertNotEquals( defaultMemory.toString(), config.getCurrentMemory().toString() );
transformation.transform( config, args );
assertEquals( defaultMemory.toString(), config.getMemory().toString() );
assertEquals( defaultMemory.toString(), config.getCurrentMemory().toString() );
assertDoesNotThrow( () -> config.validateXml() );
}
@Test
@DisplayName( "Test transformation of VM memory configuration with unspecified input data" )
public void testTransformationGenericMemoryNoData() throws TransformationException
{
final TransformationGenericMemory transformation = new TransformationGenericMemory();
final Domain config = TransformationTestUtils.getDefaultDomain();
final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
assertThrows( TransformationException.class, () -> transformation.transform( config, args ) );
}
}
|