本文整理汇总了Java中de.espirit.firstspirit.access.Language类的典型用法代码示例。如果您正苦于以下问题:Java Language类的具体用法?Java Language怎么用?Java Language使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Language类属于de.espirit.firstspirit.access包,在下文中一共展示了Language类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mockLanguage
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
/**
* Mock language.
*
* @return the language
*/
protected Language mockLanguage() {
if (language == null) {
language = context.getMock(Language.class);
reset(language);
when(language.getLocale()).thenReturn(locale);
when(language.isMasterLanguage()).thenReturn(Boolean.TRUE);
when(language.getAbbreviation()).thenReturn(locale.getLanguage());
when(language.getDisplayName((Language) any())).then(new Answer<String>() {
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
final Language mylanguage = (Language) invocation.getArguments()[0];
return locale.getDisplayLanguage(mylanguage.getLocale());
}
});
}
return language;
}
示例2: getLanguage
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
/**
* Method to get the current language.
*
* @return the current language.
*/
public Language getLanguage() {
if (workflowScriptContext == null) {
LanguageAgent languageAgent = baseContext.requestSpecialist(LanguageAgent.TYPE);
Language language = languageAgent.getMasterLanguage();
for (Language lang : languageAgent.getLanguages()) {
if (lang.getLocale().equals(locale)) {
language = lang;
break;
}
}
return language;
} else {
return workflowScriptContext.getProject().getLanguage(locale.getLanguage().toUpperCase());
}
}
示例3: setupMocks
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Override
@SuppressWarnings("squid:S1166")
public void setupMocks() {
final WebeditUiAgent uiAgent = context.requestSpecialist(WebeditUiAgent.TYPE);
final Language language = mockLanguage();
final Locale locale = language.getLocale();
when(uiAgent.getDisplayLanguage()).thenReturn(language);
when(uiAgent.getPreviewLanguage()).thenReturn(language);
when(uiAgent.getLocale()).thenReturn(locale);
try {
when(uiAgent.getLocale()).thenReturn(getLocale());
} catch (NoSuchMethodError e) {
// FS version smaller 5.2.609
}
}
示例4: mocksLanguageAgent
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
private void mocksLanguageAgent() {
final LanguageAgent agent = context.requestSpecialist(LanguageAgent.TYPE);
final Language localLanguage = mockLanguage();
when(agent.getMasterLanguage()).thenReturn(localLanguage);
when(agent.getMetaLanguage()).thenReturn(localLanguage);
when(agent.getLanguages()).thenReturn(Arrays.asList(localLanguage));
when(agent.getEditorialLanguages()).thenReturn(Arrays.asList(localLanguage));
}
示例5: testRequire
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
/**
* Test require method.
*
* @throws Exception the exception
*/
@Test
public void testRequire() throws Exception {
final LanguageAgent languageAgent = testling.requireSpecialist(LanguageAgent.TYPE);
assertThat("Expect a non null value", languageAgent, is(notNullValue()));
final Language masterLanguage = languageAgent.getMasterLanguage();
assertThat("Expect a certain locale", masterLanguage.getLocale(), is(TEST_LOCALE));
assertThat("Expect ISO 2-letter code value", masterLanguage.getAbbreviation(), is(TEST_LOCALE.getLanguage()));
assertThat("Expect display name in specific locale", masterLanguage.getDisplayName(masterLanguage),
is(TEST_LOCALE.getDisplayLanguage(TEST_LOCALE)));
}
示例6: changeDisplayName
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
/**
* Changes the displayname of given element to given displayname in given language.
*/
private static void changeDisplayName(final IDProvider element, final Language language, final String displayName) throws Exception {
element.setLock(true, false);
try {
element.getLanguageInfo(language).setDisplayName(displayName);
element.save("change displayname '" + displayName + "'", false);
} finally {
element.setLock(false, false);
}
}
示例7: testGetRefObjectsFromTemplateStoreElement
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Test
public void testGetRefObjectsFromTemplateStoreElement() throws Exception {
ReferenceEntry[] referenceEntries = new ReferenceEntry[1];
referenceEntries[0] = mock(ReferenceEntry.class);
IDProvider referencedElement = mock(IDProvider.class);
when(referenceEntries[0].getReferencedElement()).thenReturn(referencedElement);
TemplateStoreElement templateStoreElement = mock(TemplateStoreElement.class);
when(templateStoreElement.getIncomingReferences()).thenReturn(referenceEntries);
Language language = mock(Language.class);
when(language.getLocale()).thenReturn(Locale.GERMANY);
UIAgent uiAgent = mock(UIAgent.class);
when(uiAgent.getDisplayLanguage()).thenReturn(language);
Project project = mock(Project.class);
when(project.getLanguage(Locale.GERMANY.getLanguage().toUpperCase())).thenReturn(language);
WorkflowScriptContext workflowScriptContext = mock(WorkflowScriptContext.class);
when(workflowScriptContext.getWorkflowable()).thenReturn(templateStoreElement);
when(workflowScriptContext.requireSpecialist(UIAgent.TYPE)).thenReturn(uiAgent);
when(workflowScriptContext.getProject()).thenReturn(project);
WorkflowObject workflowObject = new WorkflowObject(workflowScriptContext);
List<Object> refObjectsFromStoreElement = workflowObject.getRefObjectsFromStoreElement();
verify(templateStoreElement).getIncomingReferences();
assertNotNull("List of referenced objects is null.", refObjectsFromStoreElement);
assertEquals("Number of referenced objects does not match expected amount.", referenceEntries.length, refObjectsFromStoreElement.size());
for (int i = 0; i < referenceEntries.length; i++) {
assertEquals("Referenced element does not equal expected element.", referenceEntries[i].getReferencedElement(), refObjectsFromStoreElement.get(i));
}
}
示例8: before
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
Language language = mock(Language.class);
when(language.getLocale()).thenReturn(locale);
WebeditUiAgent agent = mock(WebeditUiAgent.class);
when(agent.getDisplayLanguage()).thenReturn(language);
context = mock(BaseContext.class);
when(context.requireSpecialist(WebeditUiAgent.TYPE)).thenReturn(agent);
}
示例9: getLanguage
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Override
public Language getLanguage() {
return null;
}
示例10: mediaReferenced
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Override
public void mediaReferenced(final Media media, final Language language, final Resolution resolution) throws IOException {
throw new UnsupportedOperationException();
}
示例11: getLanguage
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Override
public Language getLanguage() {
return requestSpecialist(LanguageAgent.TYPE).getMasterLanguage();
}
示例12: setupMocks
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Override
public void setupMocks() {
final UIAgent uiAgent = context.requireSpecialist(UIAgent.TYPE);
final Language language = mockLanguage();
when(uiAgent.getDisplayLanguage()).thenReturn(language);
}
示例13: initMocks
import de.espirit.firstspirit.access.Language; //导入依赖的package包/类
@Before
public void initMocks() {
templateFolder = mock(TemplateFolder.class);
schema = mock(Schema.class);
RequestOperation.Answer noAnswer = mock(RequestOperation.Answer.class);
RequestOperation.Answer yesAnswer = mock(RequestOperation.Answer.class);
requestOperation = mock(RequestOperation.class);
when(requestOperation.addNo()).thenReturn(noAnswer);
when(requestOperation.addYes()).thenReturn(yesAnswer);
language = mock(Language.class);
when(language.getLocale()).thenReturn(Locale.GERMANY);
resourceBundle = ResourceBundle.getBundle(WorkflowConstants.MESSAGES, language.getLocale());
UIAgent uiAgent = mock(UIAgent.class);
when(uiAgent.getDisplayLanguage()).thenReturn(language);
Project project = mock(Project.class);
when(project.getLanguage(Locale.GERMANY.getLanguage().toUpperCase())).thenReturn(language);
Task task = mock(Task.class);
when(task.getCustomAttributes()).thenReturn(new HashMap<Object, Object>());
OperationAgent operationAgent = mock(OperationAgent.class);
when(operationAgent.getOperation(RequestOperation.TYPE)).thenReturn(requestOperation);
IDProvider idProvider = mock(IDProvider.class);
when(idProvider.getUidType()).thenReturn(IDProvider.UidType.TEMPLATESTORE);
when(idProvider.getUid()).thenReturn(new String());
Workflow workflow = mock(Workflow.class);
workflowScriptContext = mock(WorkflowScriptContext.class);
when(workflowScriptContext.requireSpecialist(UIAgent.TYPE)).thenReturn(uiAgent);
when(workflowScriptContext.getProject()).thenReturn(project);
when(workflowScriptContext.getTask()).thenReturn(task);
when(workflowScriptContext.requireSpecialist(OperationAgent.TYPE)).thenReturn(operationAgent);
when(workflowScriptContext.getTask().getWorkflow()).thenReturn(workflow);
Map<Object, Object> session = new HashMap<Object, Object>();
session.put(WorkflowConstants.WF_SUPPRESS_DIALOG, WorkflowConstants.TRUE);
when(workflowScriptContext.getSession()).thenReturn(session);
}