Skip to content
Snippets Groups Projects
Commit b656b0cb authored by buczekp's avatar buczekp
Browse files

[LMS-2036] more tests; leftovers from [LMS-2050]

SVN: 19944
parent 701107b3
No related branches found
No related tags found
No related merge requests found
Showing
with 104 additions and 40 deletions
......@@ -106,7 +106,7 @@ public class ManagedPropertyGrid extends TypedTableGrid<ReportRowModel>
{
return;
}
if (managedProperty.getUiDescription().getActions().length > 0)
if (managedProperty.getUiDescription().getActions().size() > 0)
{
addEntityOperationsLabel();
addEntityOperationButtons();
......
......@@ -67,9 +67,9 @@ public class ManagedUiActionDescription implements IManagedUiAction, ISerializab
return this;
}
public IManagedInputWidgetDescription[] getInputWidgetDescriptions()
public List<IManagedInputWidgetDescription> getInputWidgetDescriptions()
{
return inputWidgets.toArray(new IManagedInputWidgetDescription[inputWidgets.size()]);
return inputWidgets;
}
public void setInputWidgetDescriptions(List<IManagedInputWidgetDescription> widgetDescriptions)
......
......@@ -66,9 +66,9 @@ public class ManagedUiDescription implements IManagedUiDescription, ISerializabl
return action;
}
public IManagedUiAction[] getActions()
public List<IManagedUiAction> getActions()
{
return actions.toArray(new IManagedUiAction[actions.size()]);
return actions;
}
public void useTableOutput(ITableModel tableModel)
......
......@@ -80,14 +80,9 @@ public class ManagedUiTableActionDescription extends ManagedUiActionDescription
return this;
}
public int[] getSelectedRows()
public List<Integer> getSelectedRows()
{
int[] result = new int[selectedRows.size()];
for (int i = 0; i < result.length; i++)
{
result[i] = selectedRows.get(i);
}
return result;
return selectedRows;
}
public void setSelectedRows(List<Integer> selectedRows)
......
......@@ -16,6 +16,8 @@
package ch.systemsx.cisd.openbis.generic.shared.basic.dto.api;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.shared.basic.ISerializable;
/**
......@@ -64,10 +66,10 @@ public interface IManagedUiAction extends ISerializable
public IManagedInputWidgetDescription addComboBoxInputField(String labels, String[] values);
/**
* Returns an array of objects describing input widgets that will be used in user interface user
* Returns list of objects describing input widgets that will be used in user interface user
* interface for modification of the managed property.
*/
public IManagedInputWidgetDescription[] getInputWidgetDescriptions();
public List<IManagedInputWidgetDescription> getInputWidgetDescriptions();
/**
* Convenience method returning value of input widget with given label or null if such widget
......
......@@ -16,6 +16,8 @@
package ch.systemsx.cisd.openbis.generic.shared.basic.dto.api;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.shared.basic.ISerializable;
/**
......@@ -35,7 +37,7 @@ public interface IManagedUiDescription extends ISerializable
IManagedUiTableAction addTableAction(String name);
IManagedUiAction[] getActions();
List<IManagedUiAction> getActions();
/**
* Returns description of the widget that will be shown in detail view of the entity owning the
......
......@@ -16,6 +16,7 @@
package ch.systemsx.cisd.openbis.generic.shared.basic.dto.api;
import java.util.List;
import java.util.Map;
/**
......@@ -61,7 +62,7 @@ public interface IManagedUiTableAction extends IManagedUiAction
/**
* Returns list of indices of selected rows (empty if no row was selected).
*/
int[] getSelectedRows();
List<Integer> getSelectedRows();
/**
* Adds a binding between input field and table column.
......
......@@ -24,9 +24,10 @@ import ch.systemsx.cisd.common.logging.LogInitializer;
import ch.systemsx.cisd.openbis.generic.server.business.bo.AbstractBOTest;
import ch.systemsx.cisd.openbis.generic.shared.CommonTestUtils;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialIdentifier;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier;
import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.IEntityLinkElement;
import ch.systemsx.cisd.openbis.generic.shared.managed_property.structured.ElementFactory;
......@@ -62,30 +63,57 @@ public class EntityInformationProviderTest extends AbstractBOTest
IEntityLinkElement datasetLink = elementFactory.createDataSetLink(dPermId);
final SamplePE sample = CommonTestUtils.createSample();
final ExperimentPE experiment =
CommonTestUtils.createExperiment(new ExperimentIdentifier("proj", "exp"));
final ExperimentPE experiment = CommonTestUtils.createExperiment();
final DataPE dataSet = CommonTestUtils.createDataSet();
final MaterialPE material = CommonTestUtils.createMaterial(mCode, mTypeCode);
context.checking(new Expectations()
{
{
one(sampleDAO).tryToFindByPermID(sPermId);
will(returnValue(sample));
one(experimentDAO).tryGetByPermID(ePermId);
will(returnValue(experiment));
one(materialDAO).tryFindMaterial(new MaterialIdentifier(mCode, mTypeCode));
// will(returnValue(any(MaterialPE.class)));
one(externalDataDAO).tryToFindDataSetByCode(dPermId);
// will(returnValue(any(DataPE.class)));
will(returnValue(dataSet));
one(materialDAO).tryFindMaterial(new MaterialIdentifier(mCode, mTypeCode));
will(returnValue(material));
}
});
String sIdentifier = provider.getIdentifier(sampleLink);
assertEquals(sample.getIdentifier(), sIdentifier);
String eIdentifier = provider.getIdentifier(experimentLink);
assertEquals(experiment.getIdentifier(), eIdentifier);
String mIdentifier = provider.getIdentifier(materialLink);
String dIdentifier = provider.getIdentifier(datasetLink);
}
assertEquals(dataSet.getIdentifier(), dIdentifier);
String mIdentifier = provider.getIdentifier(materialLink);
assertEquals(MaterialIdentifier.print(mCode, mTypeCode), mIdentifier);
// get identifiers of missing entities
final String fakePermId = "fakePermId";
final String fakeMCode = "fakeMCode";
final String fakeMTypeCode = "fakeMTypeCode";
context.checking(new Expectations()
{
{
one(sampleDAO).tryToFindByPermID(fakePermId);
will(returnValue(null));
one(experimentDAO).tryGetByPermID(fakePermId);
will(returnValue(null));
one(externalDataDAO).tryToFindDataSetByCode(fakePermId);
will(returnValue(null));
one(materialDAO).tryFindMaterial(
new MaterialIdentifier(fakeMCode, fakeMTypeCode));
will(returnValue(null));
}
});
assertNull(provider.getIdentifier(elementFactory.createSampleLink(fakePermId)));
assertNull(provider.getIdentifier(elementFactory.createExperimentLink(fakePermId)));
assertNull(provider.getIdentifier(elementFactory.createDataSetLink(fakePermId)));
assertNull(provider.getIdentifier(elementFactory.createMaterialLink(fakeMCode,
fakeMTypeCode)));
}
}
......@@ -24,6 +24,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode;
import ch.systemsx.cisd.openbis.generic.shared.dto.AttachmentContentPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.AttachmentPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EntityPropertyPE;
......@@ -33,6 +35,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPropertyPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePropertyTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
......@@ -81,6 +84,10 @@ public class CommonTestUtils
private static final String SAMPLE_TYPE = "SAMPLE_TYPE";
private static final String DATA_SET_CODE = "20081105092158673-1";
private static final String DATA_SET_TYPE = "PROPRIETARY";
public static final String USER_ID = "test";
private static final String MATERIAL_TYPE_VIRUS = "MATERIAL_TYPE_VIRUS";
......@@ -288,6 +295,25 @@ public class CommonTestUtils
return samplePE;
}
public static final DataPE createDataSet()
{
final DataPE dataPE = new DataPE();
dataPE.setCode(CommonTestUtils.DATA_SET_CODE);
final DataSetTypePE dataSetTypePE = new DataSetTypePE();
dataSetTypePE.setCode(CommonTestUtils.DATA_SET_TYPE);
dataPE.setDataSetType(dataSetTypePE);
return dataPE;
}
public static final MaterialPE createMaterial(String materialCode, String typeCode)
{
final MaterialPE materialPE = new MaterialPE();
materialPE.setCode(materialCode);
final MaterialTypePE materialTypePE = createMaterialType(typeCode);
materialPE.setMaterialType(materialTypePE);
return materialPE;
}
public static final ExperimentIdentifier createExperimentIdentifier()
{
final ExperimentIdentifier identifier =
......@@ -295,6 +321,11 @@ public class CommonTestUtils
return identifier;
}
public static final ExperimentPE createExperiment()
{
return createExperiment(createExperimentIdentifier());
}
public static final ExperimentPE createExperiment(final ExperimentIdentifier ei)
{
final ExperimentPE exp = new ExperimentPE();
......@@ -325,9 +356,13 @@ public class CommonTestUtils
public static MaterialTypePE createMaterialType()
{
return createMaterialType(MATERIAL_TYPE_VIRUS);
}
public static MaterialTypePE createMaterialType(String typeCode)
{
final MaterialTypePE type = new MaterialTypePE();
type.setCode(MATERIAL_TYPE_VIRUS);
type.setCode(typeCode);
type.setDatabaseInstance(createHomeDatabaseInstance());
return type;
}
......
......@@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.shared.managed_property;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.testng.AssertJUnit;
......@@ -150,33 +151,33 @@ public class ManagedPropertyEvaluatorTest extends AssertJUnit
evaluator.configureUI(managedProperty);
assertEquals(false, managedProperty.isOwnTab());
IManagedUiAction[] actions = managedProperty.getUiDescription().getActions();
assertEquals(1, actions.length);
IManagedUiAction action = actions[0];
List<IManagedUiAction> actions = managedProperty.getUiDescription().getActions();
assertEquals(1, actions.size());
IManagedUiAction action = actions.get(0);
assertEquals("Create", action.getName());
IManagedInputWidgetDescription[] inputWidgets = action.getInputWidgetDescriptions();
assertEquals(5, inputWidgets.length);
checkInputFieldWidget(inputWidgets[0], ManagedInputFieldType.TEXT, "t1", null, null,
List<IManagedInputWidgetDescription> inputWidgets = action.getInputWidgetDescriptions();
assertEquals(5, inputWidgets.size());
checkInputFieldWidget(inputWidgets.get(0), ManagedInputFieldType.TEXT, "t1", null, null,
false);
checkInputFieldWidget(inputWidgets[1], ManagedInputFieldType.TEXT, "t2", "default 2",
checkInputFieldWidget(inputWidgets.get(1), ManagedInputFieldType.TEXT, "t2", "default 2",
null, false);
checkInputFieldWidget(inputWidgets[2], ManagedInputFieldType.TEXT, "t3", null,
checkInputFieldWidget(inputWidgets.get(2), ManagedInputFieldType.TEXT, "t3", null,
"description 3", false);
checkInputFieldWidget(inputWidgets[3], ManagedInputFieldType.MULTILINE_TEXT, "multi",
checkInputFieldWidget(inputWidgets.get(3), ManagedInputFieldType.MULTILINE_TEXT, "multi",
"default m", "multiline", false);
checkInputFieldWidget(inputWidgets[4], ManagedInputFieldType.COMBO_BOX, "combo", null,
checkInputFieldWidget(inputWidgets.get(4), ManagedInputFieldType.COMBO_BOX, "combo", null,
"select from list", true);
if (inputWidgets[4] instanceof ManagedComboBoxInputWidgetDescription)
if (inputWidgets.get(4) instanceof ManagedComboBoxInputWidgetDescription)
{
ManagedComboBoxInputWidgetDescription comboBox =
(ManagedComboBoxInputWidgetDescription) inputWidgets[4];
(ManagedComboBoxInputWidgetDescription) inputWidgets.get(4);
assertEquals("[v1, v2, v3]", comboBox.getOptions().toString());
} else
{
fail("expected instance of "
+ ManagedComboBoxInputWidgetDescription.class.getSimpleName() + ", got "
+ inputWidgets[4].getClass().getSimpleName());
+ inputWidgets.get(4).getClass().getSimpleName());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment