Search in sources :

Example 1 with LocalizationRow

use of com.developmentontheedge.be5.metadata.model.EntityLocalizations.LocalizationRow in project be5 by DevelopmentOnTheEdge.

the class EntityLocalizationsTest method testLocalizations.

@Test
public void testLocalizations() {
    Project proj = new Project("test");
    proj.getApplication().getLocalizations().addLocalization("de", "entity", Arrays.asList("@AllQueries", "topic"), "Hello", "Guten Tag");
    Entity entity = new Entity("entity", proj.getApplication(), EntityType.TABLE);
    DataElementUtils.save(entity);
    DataElementUtils.save(new Query("testQuery", entity));
    DataElementUtils.save(new Query("testQuery2", entity));
    EntityLocalizations el = proj.getApplication().getLocalizations().get("de").get("entity");
    Set<LocalizationRow> expected = StreamEx.of("testQuery", "testQuery2", "topic").map(topic -> new EntityLocalizations.LocalizationRow(topic, "Hello", "Guten Tag")).toSet();
    assertEquals(expected, el.getRawRows());
    assertEquals(expected, el.getRows());
    el.remove("Hello", Collections.singleton("topic"));
    expected = StreamEx.of("testQuery", "testQuery2").map(topic -> new EntityLocalizations.LocalizationRow(topic, "Hello", "Guten Tag")).toSet();
    assertEquals(expected, el.getRawRows());
    assertEquals(expected, el.getRows());
}
Also used : Arrays(java.util.Arrays) LocalizationRow(com.developmentontheedge.be5.metadata.model.EntityLocalizations.LocalizationRow) StreamEx(one.util.streamex.StreamEx) Set(java.util.Set) Test(org.junit.Test) Assert(org.junit.Assert) Collections(java.util.Collections) LocalizationRow(com.developmentontheedge.be5.metadata.model.EntityLocalizations.LocalizationRow) LocalizationRow(com.developmentontheedge.be5.metadata.model.EntityLocalizations.LocalizationRow) Test(org.junit.Test)

Aggregations

LocalizationRow (com.developmentontheedge.be5.metadata.model.EntityLocalizations.LocalizationRow)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Set (java.util.Set)1 StreamEx (one.util.streamex.StreamEx)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1