Search in sources :

Example 1 with BarImpl

use of org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl in project ovirt-engine by oVirt.

the class MappingLocatorTest method testStaticTemplatedFooToBarClassMapper.

@Test
public void testStaticTemplatedFooToBarClassMapper() {
    Mapper<FooImpl, BarImpl> mapper = mappingLocator.getMapper(FooImpl.class, BarImpl.class);
    assertNotNull(mapper);
    BarImpl bar = mapper.map(new FooImpl("foo"), new BarImpl("overwrite", "keep"));
    assertEquals("foo", bar.get());
    assertEquals("keep", bar.other());
}
Also used : BarImpl(org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl) FooImpl(org.ovirt.engine.api.restapi.test.mappers.impl.FooImpl) Test(org.junit.Test)

Example 2 with BarImpl

use of org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl in project ovirt-engine by oVirt.

the class MappingLocatorTest method testStaticBarToFooInterfaceMapper.

@Test
public void testStaticBarToFooInterfaceMapper() {
    Mapper<IBar, IFoo> mapper = mappingLocator.getMapper(IBar.class, IFoo.class);
    assertNotNull(mapper);
    IFoo foo = mapper.map(new BarImpl("bar"), null);
    assertEquals("bar", foo.get());
}
Also used : IBar(org.ovirt.engine.api.restapi.test.mappers.api.IBar) BarImpl(org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl) IFoo(org.ovirt.engine.api.restapi.test.mappers.api.IFoo) Test(org.junit.Test)

Example 3 with BarImpl

use of org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl in project ovirt-engine by oVirt.

the class MappingLocatorTest method testStaticBarToFooClassMapper.

@Test
public void testStaticBarToFooClassMapper() {
    Mapper<BarImpl, FooImpl> mapper = mappingLocator.getMapper(BarImpl.class, FooImpl.class);
    assertNotNull(mapper);
    IFoo foo = mapper.map(new BarImpl("bar"), null);
    assertEquals("bar", foo.get());
}
Also used : BarImpl(org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl) FooImpl(org.ovirt.engine.api.restapi.test.mappers.impl.FooImpl) IFoo(org.ovirt.engine.api.restapi.test.mappers.api.IFoo) Test(org.junit.Test)

Example 4 with BarImpl

use of org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl in project ovirt-engine by oVirt.

the class StaticMapper method mapFooToBarClasses.

@Mapping(from = FooImpl.class, to = BarImpl.class)
public static BarImpl mapFooToBarClasses(IFoo foo, BarImpl template) {
    BarImpl bar = template != null ? template : new BarImpl();
    bar.set(foo.get());
    return bar;
}
Also used : BarImpl(org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 5 with BarImpl

use of org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl in project ovirt-engine by oVirt.

the class StaticMapper method mapFooToBarInterfaces.

@Mapping(from = IFoo.class, to = IBar.class)
public static IBar mapFooToBarInterfaces(IFoo foo, IBar template) {
    IBar bar = template != null ? template : new BarImpl();
    bar.set(foo.get());
    return bar;
}
Also used : IBar(org.ovirt.engine.api.restapi.test.mappers.api.IBar) BarImpl(org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Aggregations

BarImpl (org.ovirt.engine.api.restapi.test.mappers.impl.BarImpl)7 Test (org.junit.Test)5 FooImpl (org.ovirt.engine.api.restapi.test.mappers.impl.FooImpl)4 IBar (org.ovirt.engine.api.restapi.test.mappers.api.IBar)3 IFoo (org.ovirt.engine.api.restapi.test.mappers.api.IFoo)2 Mapping (org.ovirt.engine.api.restapi.types.Mapping)2