Package com.inspiresoftware.lib.dto.geda.assembler.extension

Examples of com.inspiresoftware.lib.dto.geda.assembler.extension.MethodSynthesizer


   * @throws GeDAException exception
   */
  @Test
  public void testCGLibConfigConstructor() throws GeDAException {
    final MethodSynthesizerProxy proxy = new MethodSynthesizerProxy(this.getClass().getClassLoader(), "bcel");
    final MethodSynthesizer syn = proxy.getSynthesizer();
    assertTrue(syn instanceof BCELMethodSynthesizer);
  }
View Full Code Here


   */
  @Test
  public void testClassnameConfig() throws GeDAException {
    final MethodSynthesizerProxy proxy = new MethodSynthesizerProxy(this.getClass().getClassLoader());
    proxy.configure("synthesizerImpl", JavassistMethodSynthesizer.class.getCanonicalName());
    final MethodSynthesizer syn = proxy.getSynthesizer();
    assertTrue(syn instanceof JavassistMethodSynthesizer);
  }
View Full Code Here

   * @throws GeDAException exception
   */
  @Test
  public void testClassnameConfigConstructor() throws GeDAException {
    final MethodSynthesizerProxy proxy = new MethodSynthesizerProxy(this.getClass().getClassLoader(), JavassistMethodSynthesizer.class.getCanonicalName());
    final MethodSynthesizer syn = proxy.getSynthesizer();
    assertTrue(syn instanceof JavassistMethodSynthesizer);
  }
View Full Code Here

   * @throws GeDAException exception
   */
  @Test
  public void testInstanceConfig() throws GeDAException {
    final MethodSynthesizerProxy proxy = new MethodSynthesizerProxy(this.getClass().getClassLoader());
    final MethodSynthesizer mock = new MethodSynthesizer() {
      public DataReader synthesizeReader(final PropertyDescriptor descriptor)
          throws InspectionPropertyNotFoundException,
          UnableToCreateInstanceException, GeDARuntimeException { return null; }
      public DataWriter synthesizeWriter(final PropertyDescriptor descriptor)
          throws InspectionPropertyNotFoundException,
          UnableToCreateInstanceException, GeDARuntimeException { return null; }
      public boolean configure(final String configuration, final Object value) { return false; }
            public void releaseResources() { }
        };
    proxy.configure("synthesizerImpl", mock);
    final MethodSynthesizer syn = proxy.getSynthesizer();
    assertSame(syn, mock);
  }
View Full Code Here

   * Test class name setup.
   * @throws GeDAException exception
   */
  @Test
  public void testInstanceConfigConstructor() throws GeDAException {
    final MethodSynthesizer mock = new MethodSynthesizer() {
      public DataReader synthesizeReader(final PropertyDescriptor descriptor)
          throws InspectionPropertyNotFoundException,
          UnableToCreateInstanceException, GeDARuntimeException { return null; }
      public DataWriter synthesizeWriter(final PropertyDescriptor descriptor)
          throws InspectionPropertyNotFoundException,
          UnableToCreateInstanceException, GeDARuntimeException { return null; }
      public boolean configure(final String configuration, final Object value) { return false; }
            public void releaseResources() { }
        };
    final MethodSynthesizerProxy proxy = new MethodSynthesizerProxy(this.getClass().getClassLoader(), mock);
    final MethodSynthesizer syn = proxy.getSynthesizer();
    assertSame(syn, mock);
  }
View Full Code Here

   */
  @Test(expected = UnableToCreateInstanceException.class)
  public void testWrongConfigThrowsException() throws GeDAException {
    final MethodSynthesizerProxy proxy = new MethodSynthesizerProxy(this.getClass().getClassLoader());
    proxy.configure("synthesizerImpl", new Integer(1));
    final MethodSynthesizer syn = proxy.getSynthesizer();
    assertTrue(syn instanceof JavassistMethodSynthesizer);
  }
View Full Code Here

   * @throws GeDAException exception
   */
  @Test(expected = UnableToCreateInstanceException.class)
  public void testWrongConfigConstructorThrowsException() throws GeDAException {
    final MethodSynthesizerProxy proxy = new MethodSynthesizerProxy(this.getClass().getClassLoader(), new Integer(1));
    final MethodSynthesizer syn = proxy.getSynthesizer();
    assertTrue(syn instanceof JavassistMethodSynthesizer);
  }
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void testHashCodeAndEqualsOfInitialised() throws Exception {
        final MethodSynthesizer mock = new MethodSynthesizer() {
            public DataReader synthesizeReader(final PropertyDescriptor descriptor)
                    throws InspectionPropertyNotFoundException,
                    UnableToCreateInstanceException, GeDARuntimeException { return null; }
            public DataWriter synthesizeWriter(final PropertyDescriptor descriptor)
                    throws InspectionPropertyNotFoundException,
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testHashCodeAndEqualsOfProxyToReal() throws Exception {

        final MethodSynthesizer mock = new MethodSynthesizer() {
            public DataReader synthesizeReader(final PropertyDescriptor descriptor)
                    throws InspectionPropertyNotFoundException,
                    UnableToCreateInstanceException, GeDARuntimeException { return null; }
            public DataWriter synthesizeWriter(final PropertyDescriptor descriptor)
                    throws InspectionPropertyNotFoundException,
                    UnableToCreateInstanceException, GeDARuntimeException { return null; }
            public boolean configure(final String configuration, final Object value) { return false; }
            public void releaseResources() { }
        };

        final MethodSynthesizerProxy proxy1 = new MethodSynthesizerProxy(this.getClass().getClassLoader(), mock);

        assertEquals(proxy1.hashCode(), mock.hashCode());
        assertTrue(proxy1.equals(mock));
        assertFalse(mock.equals(proxy1)); // But not other way round!

    }
View Full Code Here

           AnnotationValidatingBindingException, GeDARuntimeException  {

        final PropertyDescriptor dtoFieldDesc = PropertyInspector.getDtoPropertyDescriptorForField(
                dtoClass, meta.getDtoFieldName(), dtoPropertyDescriptors);

        final MethodSynthesizer synthesizer = context.getMethodSynthesizer();

        final DataReader dtoFieldRead = meta.isReadOnly() ? null : synthesizer.synthesizeReader(dtoFieldDesc);
        final DataWriter dtoFieldWrite = synthesizer.synthesizeWriter(dtoFieldDesc);

        final boolean isMapEntity = Map.class.isAssignableFrom(entityClass);
        final boolean isListEntity = !isMapEntity && List.class.isAssignableFrom(entityClass);

        final MethodSynthesizer entitySynthesizer;
        final PropertyDescriptor entityFieldDesc;

        if (isMapEntity || isListEntity) {
            if (isMapEntity) {
                entitySynthesizer = mapSynthesizer;
            } else {
                entitySynthesizer = listSynthesizer;
            }
            entityFieldDesc = dtoFieldDesc;
        } else {
            entitySynthesizer = synthesizer;
            entityFieldDesc = PropertyInspector.getEntityPropertyDescriptorForField(
            dtoClass, entityClass, meta.getDtoFieldName(), meta.getEntityFieldName(), entityPropertyDescriptors);
        }

    final DataReader entityFieldRead = entitySynthesizer.synthesizeReader(entityFieldDesc);
    final DataWriter entityFieldWrite = meta.isReadOnly() ? null : entitySynthesizer.synthesizeWriter(entityFieldDesc);

        return new CollectionPipe(context,
                dtoFieldRead, dtoFieldWrite,
                entityFieldRead, entityFieldWrite,
                meta);
View Full Code Here

TOP

Related Classes of com.inspiresoftware.lib.dto.geda.assembler.extension.MethodSynthesizer

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.