|
| 1 | +package org.apache.cloudstack.api.command.admin.gpu; |
| 2 | + |
| 3 | +import com.cloud.user.Account; |
| 4 | +import org.junit.Test; |
| 5 | +import org.springframework.test.util.ReflectionTestUtils; |
| 6 | + |
| 7 | +import static org.junit.Assert.assertEquals; |
| 8 | +import static org.junit.Assert.assertNull; |
| 9 | + |
| 10 | +public class CreateVgpuProfileCmdTest { |
| 11 | + |
| 12 | + @Test |
| 13 | + public void getName() { |
| 14 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 15 | + assertNull(cmd.getName()); |
| 16 | + String name = "Test VGPU Profile"; |
| 17 | + ReflectionTestUtils.setField(cmd, "name", name); |
| 18 | + assertEquals(name, cmd.getName()); |
| 19 | + } |
| 20 | + |
| 21 | + @Test |
| 22 | + public void getDescription() { |
| 23 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 24 | + assertNull(cmd.getDescription()); |
| 25 | + String description = "Test VGPU Profile Description"; |
| 26 | + ReflectionTestUtils.setField(cmd, "description", description); |
| 27 | + assertEquals(description, cmd.getDescription()); |
| 28 | + } |
| 29 | + |
| 30 | + @Test |
| 31 | + public void getCardId() { |
| 32 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 33 | + assertNull(cmd.getCardId()); |
| 34 | + Long cardId = 1L; |
| 35 | + ReflectionTestUtils.setField(cmd, "cardId", cardId); |
| 36 | + assertEquals(cardId, cmd.getCardId()); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + public void getMaxVgpuPerPgpu() { |
| 41 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 42 | + assertNull(cmd.getMaxVgpuPerPgpu()); |
| 43 | + Long maxVgpuPerPgpu = 8L; |
| 44 | + ReflectionTestUtils.setField(cmd, "maxVgpuPerPgpu", maxVgpuPerPgpu); |
| 45 | + assertEquals(maxVgpuPerPgpu, cmd.getMaxVgpuPerPgpu()); |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + public void getVideoRam() { |
| 50 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 51 | + assertNull(cmd.getVideoRam()); |
| 52 | + Long videoRam = 8192L; // 8 GB |
| 53 | + ReflectionTestUtils.setField(cmd, "videoRam", videoRam); |
| 54 | + assertEquals(videoRam, cmd.getVideoRam()); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void getMaxHeads() { |
| 59 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 60 | + assertNull(cmd.getMaxHeads()); |
| 61 | + Long maxHeads = 2L; |
| 62 | + ReflectionTestUtils.setField(cmd, "maxHeads", maxHeads); |
| 63 | + assertEquals(maxHeads, cmd.getMaxHeads()); |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void getMaxResolutionX() { |
| 68 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 69 | + assertNull(cmd.getMaxResolutionX()); |
| 70 | + Long maxResolutionX = 1920L; // 1920 pixels |
| 71 | + ReflectionTestUtils.setField(cmd, "maxResolutionX", maxResolutionX); |
| 72 | + assertEquals(maxResolutionX, cmd.getMaxResolutionX()); |
| 73 | + } |
| 74 | + |
| 75 | + @Test |
| 76 | + public void getMaxResolutionY() { |
| 77 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 78 | + assertNull(cmd.getMaxResolutionY()); |
| 79 | + Long maxResolutionY = 1080L; // 1080 pixels |
| 80 | + ReflectionTestUtils.setField(cmd, "maxResolutionY", maxResolutionY); |
| 81 | + assertEquals(maxResolutionY, cmd.getMaxResolutionY()); |
| 82 | + } |
| 83 | + |
| 84 | + @Test |
| 85 | + public void getEntityOwnerId() { |
| 86 | + CreateVgpuProfileCmd cmd = new CreateVgpuProfileCmd(); |
| 87 | + assertEquals(Account.ACCOUNT_ID_SYSTEM, cmd.getEntityOwnerId()); |
| 88 | + } |
| 89 | +} |
0 commit comments