summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericUuidTest.java
blob: 03534d8ee039b17cfd5cfe53838592d3853562bc (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
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 org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.openslx.libvirt.domain.Domain;
import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
import org.openslx.virtualization.configuration.transformation.TransformationException;

public class TransformationGenericUuidTest
{
	@Test
	@DisplayName( "Test transformation of VM UUID configuration" )
	public void testTransformationGenericUuid() throws TransformationException
	{
		final TransformationGenericUuid transformation = new TransformationGenericUuid();
		final Domain config = TransformationTestUtils.getDefaultDomain();
		final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();

		assertNotEquals( TransformationTestUtils.DEFAULT_VM_UUID, config.getUuid() );

		transformation.transform( config, args );

		assertEquals( TransformationTestUtils.DEFAULT_VM_UUID, config.getUuid() );

		assertDoesNotThrow( () -> config.validateXml() );
	}

	@Test
	@DisplayName( "Test transformation of VM UUID configuration with unspecified input data" )
	public void testTransformationGenericUuidNoData() throws TransformationException
	{
		final TransformationGenericUuid transformation = new TransformationGenericUuid();
		final Domain config = TransformationTestUtils.getDefaultDomain();
		final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();

		assertThrows( TransformationException.class, () -> transformation.transform( config, args ) );
	}
}