package com.abstratt.kirra.rest.tests;

import java.util.List;
import java.util.stream.IntStream;

import com.abstratt.kirra.Instance;

public class InstanceTests extends AbstractRestTests {
	public void testCreateInstance() {
		Instance newInstance = new Instance("expenses", "Expense");
		newInstance.setValue("amount", 10);

		assertTrue(newInstance.isNew());
		Instance created = instanceManagement.createInstance(newInstance);
		assertFalse(created.isNew());
		assertEquals(10.0, created.getValue("amount"));
	}

	public void testGetInstance() {
		Instance newInstance = new Instance("expenses", "Expense");
		newInstance.setValue("amount", 10);
		Instance created = instanceManagement.createInstance(newInstance);
		Instance retrieved = instanceManagement.getInstance("expenses", "Expense", created.getObjectId(), false);
		assertEquals(10.0, retrieved.getValue("amount"));
	}
	
	public void testGetInstances() {
		int count = 4;
		IntStream.range(0, count).forEach(i -> instanceManagement.createInstance(new Instance("expenses", "Expense")));
		List<Instance> retrieved = instanceManagement.getInstances("expenses", "Expense", false);
		assertEquals(count, retrieved.size());
	}
}
@@ -83,19 +83,16 @@
 .stream.
-Int
 Stream;%0D
@@ -328,18 +328,16 @@
 , 10);%0D%0A
-%0D%0A
 %09%09assert
@@ -900,11 +900,10 @@
 %09%7D%0D%0A
-%09
 %0D%0A
+
 %09pub
@@ -951,49 +951,33 @@
 t = 
-4
+10
 ;%0D%0A%09%09
-Int
 Stream.
-range(0, count).forEach(i
+generate(()
  -%3E 
@@ -1047,16 +1047,37 @@
 ense%22)))
+.limit(count).count()
 ;%0D%0A%09%09Lis

better way to generate a list