use of org.talend.mdm.repository.model.mdmproperties.WSDataModelItem in project tmdm-studio-se by Talend.
the class DatamodelOperatorUpdatorTest method testUpdateConditionOperator.
@Test
public void testUpdateConditionOperator() {
// $NON-NLS-1$
String filename = "Product_0.1.xsd";
// $NON-NLS-1$
File file = new File("temp/" + filename);
try {
byte[] fbyteArray = IOUtils.toByteArray(new FileInputStream(file));
WSDataModelItem wsdataModelItem = MdmpropertiesFactory.eINSTANCE.createWSDataModelItem();
ReferenceFileItem xsdFileItem = PropertiesFactory.eINSTANCE.createReferenceFileItem();
ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
//
byteArray = spy(byteArray);
//
when(byteArray.getInnerContent()).thenReturn(fbyteArray);
xsdFileItem.setContent(byteArray);
xsdFileItem.setExtension("xsd");
wsdataModelItem.getReferenceResources().add(xsdFileItem);
WSDataModelE wsdataModelE = MdmserverobjectFactory.eINSTANCE.createWSDataModelE();
wsdataModelE.setXsdSchema(null);
wsdataModelItem.setWsDataModel(wsdataModelE);
PowerMockito.mockStatic(RepositoryResourceUtil.class);
boolean updated = new DatamodelOperatorUpdator().updateConditionOperator(wsdataModelItem);
String xsdSchema = wsdataModelItem.getWsDataModel().getXsdSchema();
assertTrue(updated);
assertNotNull(xsdSchema);
// $NON-NLS-1$
assertFalse(xsdSchema.contains("Strict Contains"));
// $NON-NLS-1$
assertFalse(xsdSchema.contains("Contains Text Of"));
// $NON-NLS-1$
assertTrue(xsdSchema.contains("Contains"));
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.talend.mdm.repository.model.mdmproperties.WSDataModelItem in project tmdm-studio-se by Talend.
the class DataModelMainPage2 method updateSchemaToItem.
//
public Item updateSchemaToItem(Item item) {
WSDataModelE wsDataModelE = ((WSDataModelItem) item).getWsDataModel();
WSDataModel wsDataModel = (WSDataModel) xobject.getWsObject();
wsDataModelE.setXsdSchema(wsDataModel.getXsdSchema());
return item;
}
use of org.talend.mdm.repository.model.mdmproperties.WSDataModelItem in project tmdm-studio-se by Talend.
the class DataModelNodeResourceProvider method save.
@Override
public Resource save(Item item) throws PersistenceException {
if (item instanceof WSDataModelItem) {
Resource resource = xmiResourceManager.getItemResource(item);
resource.getContents().clear();
resource.getContents().add(((WSDataModelItem) item).getWsDataModel());
return resource;
}
return null;
}
Aggregations