Java Code Examples for org.alfresco.service.cmr.repository.MLText#addValue()
The following examples show how to use
org.alfresco.service.cmr.repository.MLText#addValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MLPropertyInterceptor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Replace any text in mlText having the same language (but any variant) as contentLocale * with updatedText keyed by the language of contentLocale. This ensures that the mlText * will have no more than one entry for the particular language. * * @param contentLocale Locale * @param updatedText String * @param mlText MLText */ private void replaceTextForLanguage(Locale contentLocale, String updatedText, MLText mlText) { String language = contentLocale.getLanguage(); // Remove all text entries having the same language as the chosen contentLocale // (e.g. if contentLocale is en_GB, then remove text for en, en_GB, en_US etc. Iterator<Locale> locales = mlText.getLocales().iterator(); while (locales.hasNext()) { Locale locale = locales.next(); if (locale.getLanguage().equals(language)) { locales.remove(); } } // Add the new value for the specific language mlText.addValue(new Locale(language), updatedText); }
Example 2
Source File: DBQueryTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @return properties */ public Map<QName, Serializable> getOrderProperties() { Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>(); testProperties.put(CREATED_DATE, orderDate); testProperties.put(ORDER_DOUBLE, orderDoubleCount); testProperties.put(ORDER_FLOAT, orderFloatCount); testProperties.put(ORDER_LONG, orderLongCount); testProperties.put(ORDER_INT, orderIntCount); testProperties.put(ORDER_TEXT, new String(new char[] { (char) ('a' + orderTextCount) }) + " cabbage"); MLText mlText = new MLText(); mlText.addValue(Locale.ENGLISH, new String(new char[] { (char) ('a' + orderTextCount) }) + " banana"); mlText.addValue(Locale.FRENCH, new String(new char[] { (char) ('Z' - orderTextCount) }) + " banane"); mlText.addValue(Locale.CHINESE, new String(new char[] { (char) ('香' + orderTextCount) }) + " 香蕉"); testProperties.put(ORDER_ML_TEXT, mlText); orderDate = Duration.subtract(orderDate, new Duration("P1D")); orderDoubleCount += 0.1d; orderFloatCount += 0.82f; orderLongCount += 299999999999999l; orderIntCount += 8576457; orderTextCount++; return testProperties; }
Example 3
Source File: BaseNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void testMultiValueMLTextProperties() throws Exception { NodeRef nodeRef = nodeService.createNode( rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), TYPE_QNAME_TEST_MANY_ML_PROPERTIES).getChildRef(); // Create MLText properties and add to a collection List<MLText> mlTextCollection = new ArrayList<MLText>(2); MLText mlText0 = new MLText(); mlText0.addValue(Locale.ENGLISH, "Hello"); mlText0.addValue(Locale.FRENCH, "Bonjour"); mlTextCollection.add(mlText0); MLText mlText1 = new MLText(); mlText1.addValue(Locale.ENGLISH, "Bye bye"); mlText1.addValue(Locale.FRENCH, "Au revoir"); mlTextCollection.add(mlText1); nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable) mlTextCollection); Collection<MLText> mlTextCollectionCheck = (Collection<MLText>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", mlTextCollection, mlTextCollectionCheck); }
Example 4
Source File: FullNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testMLTextValues() throws Exception { // Set the server default locale Locale.setDefault(Locale.ENGLISH); MLText mlTextProperty = new MLText(); mlTextProperty.addValue(Locale.ENGLISH, "Very good!"); mlTextProperty.addValue(Locale.FRENCH, "Très bon!"); mlTextProperty.addValue(Locale.GERMAN, "Sehr gut!"); nodeService.setProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty); // Check filtered property retrieval Serializable textValueFiltered = nodeService.getProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); assertEquals( "Default locale value not taken for ML text", mlTextProperty.getValue(Locale.ENGLISH), textValueFiltered); // Check filtered mass property retrieval Map<QName, Serializable> propertiesFiltered = nodeService.getProperties(rootNodeRef); assertEquals( "Default locale value not taken for ML text in Map", mlTextProperty.getValue(Locale.ENGLISH), propertiesFiltered.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE)); }
Example 5
Source File: FullNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testLongMLTextValues() throws Exception { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 4096; i++) { sb.append(" ").append(i); } String longString = sb.toString(); // Set the server default locale Locale.setDefault(Locale.ENGLISH); // Set it as a normal string nodeService.setProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, longString); MLText mlTextProperty = new MLText(); mlTextProperty.addValue(Locale.ENGLISH, longString); mlTextProperty.addValue(Locale.FRENCH, longString); mlTextProperty.addValue(Locale.GERMAN, longString); // Set it as MLText nodeService.setProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty); }
Example 6
Source File: DbNodeServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void testMLTextValues() throws Exception { // Set the server default locale Locale.setDefault(Locale.ENGLISH); MLText mlTextProperty = new MLText(); mlTextProperty.addValue(Locale.ENGLISH, "Very good!"); mlTextProperty.addValue(Locale.FRENCH, "Très bon!"); mlTextProperty.addValue(Locale.GERMAN, "Sehr gut!"); nodeService.setProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty); // Check unfiltered property retrieval Serializable textValueDirect = nodeService.getProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); assertEquals( "MLText type not returned direct", mlTextProperty, textValueDirect); // Check unfiltered mass property retrieval Map<QName, Serializable> propertiesDirect = nodeService.getProperties(rootNodeRef); assertEquals( "MLText type not returned direct in Map", mlTextProperty, propertiesDirect.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE)); }
Example 7
Source File: DbNodeServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Ensure that plain strings going into MLText properties is handled */ @SuppressWarnings("unchecked") public void testStringIntoMLTextProperty() throws Exception { String text = "Hello"; nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, text); Serializable mlTextCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE); assertTrue("Plain string insertion should be returned as MLText", mlTextCheck instanceof MLText); Locale defaultLocale = I18NUtil.getLocale(); MLText mlTextCheck2 = (MLText) mlTextCheck; String mlTextDefaultCheck = mlTextCheck2.getDefaultValue(); assertEquals("Default MLText value was not set correctly", text, mlTextDefaultCheck); // Reset the property nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, null); Serializable nullValueCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE); // Now, just pass a String in nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, text); // Now update the property with some MLText MLText mlText = new MLText(); mlText.addValue(Locale.ENGLISH, "Very good!"); mlText.addValue(Locale.FRENCH, "Très bon!"); mlText.addValue(Locale.GERMAN, "Sehr gut!"); nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, mlText); // Get it back and check mlTextCheck = nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE); assertEquals("Setting of MLText over String failed.", mlText, mlTextCheck); }
Example 8
Source File: DbNodeServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Ensure that plain strings going into MLText properties is handled */ @SuppressWarnings("unchecked") public void testSingleStringMLTextProperty() throws Exception { // Set the property with single-value MLText MLText mlText = new MLText(); mlText.addValue(Locale.GERMAN, "Sehr gut!"); nodeService.setProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE, mlText); // Get it back and check MLText mlTextCheck = (MLText) nodeService.getProperty(rootNodeRef, PROP_QNAME_ML_TEXT_VALUE); assertEquals("Setting of MLText over String failed.", mlText, mlTextCheck); }
Example 9
Source File: ExporterComponentTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testMLText() throws Exception { NodeRef rootNode = nodeService.getRootNode(storeRef); NodeRef folderNodeRef = nodeService.createNode( rootNode, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_FOLDER).getChildRef(); FileInfo exportFolder = fileFolderService.create(folderNodeRef, "export", ContentModel.TYPE_FOLDER); FileInfo content = fileFolderService.create(exportFolder.getNodeRef(), "file", ContentModel.TYPE_CONTENT); MLText title = new MLText(); title.addValue(Locale.ENGLISH, null); title.addValue(Locale.FRENCH, "bonjour"); nodeService.setProperty(content.getNodeRef(), ContentModel.PROP_TITLE, title); nodeService.setProperty(content.getNodeRef(), ContentModel.PROP_NAME, "file"); FileInfo importFolder = fileFolderService.create(folderNodeRef, "import", ContentModel.TYPE_FOLDER); // export File acpFile = exportContent(exportFolder.getNodeRef()); // import FileInfo importFolderFileInfo = importContent(acpFile, importFolder.getNodeRef()); assertNotNull(importFolderFileInfo); NodeRef importedFileNode = fileFolderService.searchSimple(importFolderFileInfo.getNodeRef(), "file"); assertNotNull("Couldn't find imported file: file", importedFileNode); Locale currentLocale = I18NUtil.getContentLocale(); try { I18NUtil.setContentLocale(Locale.ENGLISH); String importedTitle = (String)nodeService.getProperty(importedFileNode, ContentModel.PROP_TITLE); assertNull(importedTitle); I18NUtil.setContentLocale(Locale.FRENCH); importedTitle = (String)nodeService.getProperty(importedFileNode, ContentModel.PROP_TITLE); assertNotNull(importedTitle); assertEquals("bonjour", importedTitle); } finally { I18NUtil.setContentLocale(currentLocale); } }
Example 10
Source File: CopyServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * https://issues.alfresco.com/jira/browse/ALF-3119 * * Test copying of MLText values. */ public void testCopyMLText() { // Create a folder and content node Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1); propsFolder.put(ContentModel.PROP_NAME, "tempFolder"); NodeRef folderNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef(); Map<QName, Serializable> props = new HashMap<QName, Serializable>(1); props.put(ContentModel.PROP_NAME, "myDoc.txt"); String FRENCH_DESCRIPTION = "french description"; String GERMAN_DESCRIPTION = "german description"; String ITALY_DESCRIPTION = "italy description"; String DEFAULT_DESCRIPTION = "default description"; MLText description = new MLText(); description.addValue(Locale.getDefault(), DEFAULT_DESCRIPTION); description.addValue(Locale.FRANCE, FRENCH_DESCRIPTION); description.addValue(Locale.GERMAN, GERMAN_DESCRIPTION); description.addValue(Locale.ITALY, ITALY_DESCRIPTION); props.put(ContentModel.PROP_DESCRIPTION, description); NodeRef contentNode = nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef(); NodeRef copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false); assertEquals("Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME)); QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt"); assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName()); // Test uses DB Node Service. Serializable desc = nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION); if(desc instanceof MLText) { // Using a node service without a MLProperty interceptor MLText value = (MLText)desc; assertEquals("French description is wrong", FRENCH_DESCRIPTION, value.get(Locale.FRANCE)); assertEquals("German description is wrong", GERMAN_DESCRIPTION, value.get(Locale.GERMAN)); } else { I18NUtil.setLocale(Locale.FRANCE); assertEquals("French description is wrong", FRENCH_DESCRIPTION, nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION)); I18NUtil.setLocale(Locale.GERMAN); assertEquals("German description is wrong", GERMAN_DESCRIPTION, nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION)); } }
Example 11
Source File: FullNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * ALF-3756 - original fix didn't cope with existing MLText properties having one or more variants * of a particular language. Upgrading to the fix would therefore not solve the problem properly. * <p> * For example, if a property has en_GB text in it, then 'updating' that property * with a locale of en_US will result in the addition of the en_US text rather than a true update (they're both * English, and using two slightly differently configured browsers in this way leads to confusion). */ @Test public void testMLTextUpdatedForCorrectLanguage() throws Exception { Locale.setDefault(Locale.UK); MLPropertyInterceptor.setMLAware(true); MLText mlTextProperty = new MLText(); mlTextProperty.addValue(Locale.UK, "en_GB String"); mlTextProperty.addValue(Locale.FRANCE, "fr_FR String"); // Store the MLText property nodeService.setProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty); // Pre-test check that an MLText property has been created with the correct locale/text pairs. Serializable textValue = nodeService.getProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); assertEquals(2, ((MLText) textValue).size()); assertEquals("en_GB String", ((MLText) textValue).getValue(Locale.UK)); assertEquals("fr_FR String", ((MLText) textValue).getValue(Locale.FRANCE)); // Enable MLText filtering - as this is how the repo will be used. MLPropertyInterceptor.setMLAware(false); // Retrieve the MLText - but it is filtered into an appropriate String textValue = nodeService.getProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); assertEquals("en_GB String", (String) textValue); // Update the property, only this time using a different English variant Locale.setDefault(Locale.US); // en_US nodeService.setProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, "Not using MLText for this part."); // Check that the text was updated rather than added to MLPropertyInterceptor.setMLAware(true); // no filtering - see real MLText // Check that there are not too many English strings, we don't want one for en_GB and one for en_US textValue = nodeService.getProperty( rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); assertEquals(2, ((MLText) textValue).size()); assertEquals("Text wasn't updated correctly", "Not using MLText for this part.", ((MLText) textValue).getValue(Locale.ENGLISH)); assertEquals("Failed to get text using locale it was added with", "Not using MLText for this part.", ((MLText) textValue).getClosestValue(Locale.US)); assertEquals("Failed to get text using original locale", "Not using MLText for this part.", ((MLText) textValue).getClosestValue(Locale.UK)); assertEquals("fr_FR String", ((MLText) textValue).getValue(Locale.FRANCE)); }
Example 12
Source File: FullNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Test @SuppressWarnings("unchecked") public void testMultiValueMLTextProperties() throws Exception { NodeRef nodeRef = nodeService.createNode( rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), TYPE_QNAME_TEST_MANY_ML_PROPERTIES).getChildRef(); // Create MLText properties and add to a collection List<MLText> mlTextCollection = new ArrayList<MLText>(2); MLText mlText0 = new MLText(); mlText0.addValue(Locale.ENGLISH, "Hello"); mlText0.addValue(Locale.FRENCH, "Bonjour"); mlTextCollection.add(mlText0); MLText mlText1 = new MLText(); mlText1.addValue(Locale.ENGLISH, "Bye bye"); mlText1.addValue(Locale.FRENCH, "Au revoir"); mlTextCollection.add(mlText1); nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable) mlTextCollection); I18NUtil.setContentLocale(Locale.ENGLISH); Collection<String> mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"Hello", "Bye bye"}), mlTextCollectionCheck); I18NUtil.setContentLocale(Locale.FRENCH); mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"Bonjour", "Au revoir"}), mlTextCollectionCheck); I18NUtil.setContentLocale(Locale.GERMAN); nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable)Arrays.asList(new String[]{"eins", "zwei", "drie", "vier"})); I18NUtil.setContentLocale(Locale.ENGLISH); mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"Hello", "Bye bye"}), mlTextCollectionCheck); I18NUtil.setContentLocale(Locale.FRENCH); mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"Bonjour", "Au revoir"}), mlTextCollectionCheck); I18NUtil.setContentLocale(Locale.GERMAN); mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"eins", "zwei", "drie", "vier"}), mlTextCollectionCheck); I18NUtil.setContentLocale(Locale.GERMAN); nodeService.setProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE, (Serializable)Arrays.asList(new String[]{"eins"})); I18NUtil.setContentLocale(Locale.ENGLISH); mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"Hello", "Bye bye"}), mlTextCollectionCheck); I18NUtil.setContentLocale(Locale.FRENCH); mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"Bonjour", "Au revoir"}), mlTextCollectionCheck); I18NUtil.setContentLocale(Locale.GERMAN); mlTextCollectionCheck = (Collection<String>) nodeService.getProperty(nodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("MLText collection didn't come back correctly.", Arrays.asList(new String[]{"eins"}), mlTextCollectionCheck); }
Example 13
Source File: DefaultTypeConverterTest.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
public void testToString() { assertEquals("true", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(true))); assertEquals("false", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(false))); assertEquals("v", DefaultTypeConverter.INSTANCE.convert(String.class, Character.valueOf('v'))); assertEquals("3", DefaultTypeConverter.INSTANCE.convert(String.class, Byte.valueOf("3"))); assertEquals("4", DefaultTypeConverter.INSTANCE.convert(String.class, Short.valueOf("4"))); assertEquals("5", DefaultTypeConverter.INSTANCE.convert(String.class, Integer.valueOf("5"))); assertEquals("6", DefaultTypeConverter.INSTANCE.convert(String.class, Long.valueOf("6"))); assertEquals("7.1", DefaultTypeConverter.INSTANCE.convert(String.class, Float.valueOf("7.1"))); assertEquals("NaN", DefaultTypeConverter.INSTANCE.convert(String.class, Float.NaN)); assertEquals("-Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Float.NEGATIVE_INFINITY)); assertEquals("Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Float.POSITIVE_INFINITY)); assertEquals("123.123", DefaultTypeConverter.INSTANCE.convert(String.class, Double.valueOf("123.123"))); assertEquals("NaN", DefaultTypeConverter.INSTANCE.convert(String.class, Double.NaN)); assertEquals("-Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Double.NEGATIVE_INFINITY)); assertEquals("Infinity", DefaultTypeConverter.INSTANCE.convert(String.class, Double.POSITIVE_INFINITY)); assertEquals("1234567890123456789", DefaultTypeConverter.INSTANCE.convert(String.class, new BigInteger("1234567890123456789"))); assertEquals("12345678901234567890.12345678901234567890", DefaultTypeConverter.INSTANCE.convert(String.class, new BigDecimal("12345678901234567890.12345678901234567890"))); Date date = new Date(); assertEquals(ISO8601DateFormat.format(date), DefaultTypeConverter.INSTANCE.convert(String.class, date)); assertEquals("P0Y25D", DefaultTypeConverter.INSTANCE.convert(String.class, new Duration("P0Y25D"))); assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, "woof")); // MLText MLText mlText = new MLText("woof"); mlText.addValue(Locale.SIMPLIFIED_CHINESE, "缂"); assertEquals("woof", DefaultTypeConverter.INSTANCE.convert(String.class, mlText)); // Locale assertEquals("fr_FR_", DefaultTypeConverter.INSTANCE.convert(String.class, Locale.FRANCE)); // VersionNumber assertEquals("1.2.3", DefaultTypeConverter.INSTANCE.convert(String.class, new VersionNumber("1.2.3"))); // Period assertEquals("period", DefaultTypeConverter.INSTANCE.convert(String.class, new Period("period"))); assertEquals("period|12", DefaultTypeConverter.INSTANCE.convert(String.class, new Period("period|12"))); Map<String,String> periodMap = new HashMap<>(); periodMap.put("periodType","month"); periodMap.put("expression","1"); assertEquals(new Period("month|1"), DefaultTypeConverter.INSTANCE.convert(Period.class, new Period(periodMap))); // Java Class assertEquals(this.getClass(), DefaultTypeConverter.INSTANCE.convert(Class.class, this.getClass().getName())); }