Package org.openengsb.core.api.descriptor

Examples of org.openengsb.core.api.descriptor.AttributeDefinition$AllValidValidator


        when(mock.getString("TWO")).thenReturn(mock2);

        Builder builder = AttributeDefinition.builder(mock);
        builder.name("ONE").id("123");
        MethodUtil.addEnumValues(TestEnum.class, builder);
        AttributeDefinition build = builder.build();
        List<Option> options = build.getOptions();
        Option option0 = options.get(0);
        assertThat(option0.getLabel().getString(Locale.getDefault()), equalTo(TestEnum.ONE.toString()));
        assertThat(option0.getValue().toString(), equalTo(TestEnum.ONE.toString()));
        Option option1 = options.get(1);
        assertThat(option1.getLabel().getString(Locale.getDefault()), equalTo(TestEnum.ONE.toString()));
View Full Code Here


            if ("name".equals(a.getId())) {
                break;
            }
            i++;
        }
        AttributeDefinition tmp = attributes.get(0);
        attributes.set(0, attributes.get(i));
        attributes.set(i, tmp);
        return attributes;
    }
View Full Code Here

        //get attributes from user but without reading from the input
        Map<String, String> attributes = new HashMap<String, String>();
        attributes.put("attr1", "val1");
        attributes.put("attr2", "val2");

        AttributeDefinition atr1 = createAttributeMock("attr1", "1");
        AttributeDefinition atr2 = createAttributeMock("attr2", "2");


        List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
        attributeDefinitions.add(atr1);
        attributeDefinitions.add(atr2);
View Full Code Here

        assertTrue(connectorAttributes.get("name1").equals("val1"));
        assertTrue(connectorAttributes.get("name2").equals("val2"));
    }

    private AttributeDefinition createAttributeMock(String attr1, final String id) {
        AttributeDefinition atr2 = mock(AttributeDefinition.class);
        when(atr2.getId()).thenReturn(attr1);
        when(atr2.getName()).thenAnswer(new Answer<LocalizableString>() {
            @Override
            public LocalizableString answer(InvocationOnMock invocationOnMock) throws Throwable {
                LocalizableString nameLocalizerMock = mock(LocalizableString.class);
                when(nameLocalizerMock.getString(any(Locale.class))).thenReturn("name" + id);
                return nameLocalizerMock;
            }
        });

        when(atr2.getDefaultValue()).thenAnswer(new Answer<LocalizableString>() {
            @Override
            public LocalizableString answer(InvocationOnMock invocationOnMock) throws Throwable {
                LocalizableString nameLocalizerMock = mock(LocalizableString.class);
                when(nameLocalizerMock.getString(any(Locale.class))).thenReturn("defaultValue" + id);
                return nameLocalizerMock;
            }
        });
        when(atr2.getDescription()).thenAnswer(new Answer<LocalizableString>() {
            @Override
            public LocalizableString answer(InvocationOnMock invocationOnMock) throws Throwable {
                LocalizableString nameLocalizerMock = mock(LocalizableString.class);
                when(nameLocalizerMock.getString(any(Locale.class))).thenReturn("description" + id);
                return nameLocalizerMock;
View Full Code Here

                Builder builder =
                    AttributeDefinition.builder(new PassThroughStringLocalizer()).id(propertyDescriptor.getName())
                        .name(propertyDescriptor.getDisplayName())
                        .description(propertyDescriptor.getShortDescription());
                addEnumValues(propertyDescriptor.getPropertyType(), builder);
                AttributeDefinition a = builder.build();
                attributes.add(a);
            }
        } catch (IntrospectionException ex) {
            LOGGER.error("building attribute list failed", ex);
        }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.descriptor.AttributeDefinition$AllValidValidator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.