use of au.gov.asd.tac.constellation.utilities.memory.MemoryManager in project constellation by constellation-app.
the class VisualManagerNGTest method testExportToBufferedImage.
/**
* Test of exportToBufferedImage method, of class VisualManager.
*/
@Test
public void testExportToBufferedImage() {
System.out.println("exportToBufferedImage");
try (final MockedStatic<MemoryManager> memoryManagerMockedStatic = mockStatic(MemoryManager.class)) {
memoryManagerMockedStatic.when(() -> MemoryManager.newObject(Mockito.eq(VisualManager.class))).thenAnswer((Answer<Void>) invocation -> null);
memoryManagerMockedStatic.when(() -> MemoryManager.finalizeObject(Mockito.eq(VisualManager.class))).thenAnswer((Answer<Void>) invocation -> null);
final VisualAccess access = mock(VisualAccess.class);
final BufferedImage[] imageFile = new BufferedImage[555];
final Semaphore waiter = mock(Semaphore.class);
final VisualOperation op = mock(VisualOperation.class);
final VisualProcessor processor = mock(VisualProcessor.class);
when(processor.exportToBufferedImage(Mockito.eq(imageFile), Mockito.eq(waiter))).thenReturn(op);
final VisualManager instance = new VisualManager(access, processor);
final PriorityBlockingQueue<VisualOperation> queueBefore = instance.getOperations();
final int size = queueBefore.size();
final boolean containsOP = queueBefore.contains(op);
instance.exportToBufferedImage(imageFile, waiter);
final PriorityBlockingQueue<VisualOperation> queueAfter = instance.getOperations();
assertEquals(queueAfter.size(), size + 1);
assertFalse(containsOP);
assertTrue(queueAfter.contains(op));
verify(processor, times(1)).exportToBufferedImage(Mockito.eq(imageFile), Mockito.eq(waiter));
}
}
use of au.gov.asd.tac.constellation.utilities.memory.MemoryManager in project constellation by constellation-app.
the class VisualManagerNGTest method testExportToImage.
/**
* Test of exportToImage method, of class VisualManager.
*/
@Test
public void testExportToImage() {
System.out.println("exportToImage");
try (final MockedStatic<MemoryManager> memoryManagerMockedStatic = mockStatic(MemoryManager.class)) {
memoryManagerMockedStatic.when(() -> MemoryManager.newObject(Mockito.eq(VisualManager.class))).thenAnswer((Answer<Void>) invocation -> null);
memoryManagerMockedStatic.when(() -> MemoryManager.finalizeObject(Mockito.eq(VisualManager.class))).thenAnswer((Answer<Void>) invocation -> null);
final VisualAccess access = mock(VisualAccess.class);
final File imageFile = mock(File.class);
final VisualOperation op = mock(VisualOperation.class);
final VisualProcessor processor = mock(VisualProcessor.class);
when(processor.exportToImage(Mockito.eq(imageFile))).thenReturn(op);
final VisualManager instance = new VisualManager(access, processor);
final PriorityBlockingQueue<VisualOperation> queueBefore = instance.getOperations();
final int size = queueBefore.size();
final boolean containsOP = queueBefore.contains(op);
instance.exportToImage(imageFile);
final PriorityBlockingQueue<VisualOperation> queueAfter = instance.getOperations();
assertEquals(queueAfter.size(), size + 1);
assertFalse(containsOP);
assertTrue(queueAfter.contains(op));
verify(processor, times(1)).exportToImage(Mockito.eq(imageFile));
}
}
use of au.gov.asd.tac.constellation.utilities.memory.MemoryManager in project constellation by constellation-app.
the class VisualManagerNGTest method testGetVisualComponent.
/**
* Test of getVisualComponent method, of class VisualManager.
*/
@Test
public void testGetVisualComponent() {
System.out.println("getVisualComponent");
try (final MockedStatic<MemoryManager> memoryManagerMockedStatic = mockStatic(MemoryManager.class)) {
memoryManagerMockedStatic.when(() -> MemoryManager.newObject(Mockito.eq(VisualManager.class))).thenAnswer((Answer<Void>) invocation -> null);
final VisualProcessor processor = mock(VisualProcessor.class);
final Component canvas = mock(Component.class);
when(processor.getCanvas()).thenReturn(canvas);
final VisualAccess access = mock(VisualAccess.class);
final VisualManager instance = new VisualManager(access, processor);
final Component result = instance.getVisualComponent();
assertEquals(result, canvas);
verify(processor, times(1)).getCanvas();
}
}
Aggregations