@Test public void testClone() throws CloneNotSupportedException { MasterReport bodyReport = mock( MasterReport.class ); MasterReport clonedReport = mock( MasterReport.class ); ReportProcessTaskMetaData exportTask = mock( ReportProcessTaskMetaData.class ); doReturn( "attach_type" ).when( exportTask ).getName(); ReportProcessTaskRegistry.getInstance().registerExportType( exportTask ); doReturn( clonedReport ).when( bodyReport ).clone(); MailDefinition source = new MailDefinition( "body-type", bodyReport ); source.addAttachmentReport( "attach_type", bodyReport ); Object cloned = source.clone(); assertThat( cloned, is( instanceOf( MailDefinition.class ) ) ); MailDefinition result = (MailDefinition) cloned; assertThat( result, is( not( sameInstance( source ) ) ) ); assertThat( result.getBodyReport(), is( notNullValue() ) ); assertThat( result.getBodyReport(), is( not( sameInstance( source.getBodyReport() ) ) ) ); assertThat( result.getBodyType(), is( equalTo( source.getBodyType() ) ) ); assertThat( result.getAttachmentCount(), is( equalTo( source.getAttachmentCount() ) ) ); assertThat( result.getAttachmentReport( 0 ), is( not( sameInstance( source.getAttachmentReport( 0 ) ) ) ) ); }
public Object clone() throws CloneNotSupportedException { final MailDefinition mailDefinition = (MailDefinition) super.clone(); mailDefinition.bodyReport = (MasterReport) bodyReport.clone(); mailDefinition.attachmentTypes = (ArrayList) attachmentTypes.clone(); mailDefinition.attachmentReports = (ArrayList) attachmentReports.clone(); mailDefinition.attachmentReports.clear(); for ( int i = 0; i < attachmentReports.size(); i++ ) { final MasterReport report = (MasterReport) attachmentReports.get( i ); mailDefinition.attachmentReports.add( report.clone() ); } return mailDefinition; }
MailDefinition implements Serializable, Cloneable { public Object clone() throws CloneNotSupportedException { final MailDefinition mailDefinition = (MailDefinition) super.clone(); mailDefinition.bodyReport = (MasterReport) bodyReport.clone(); mailDefinition.attachmentTypes = (ArrayList) attachmentTypes.clone(); mailDefinition.attachmentReports = (ArrayList) attachmentReports.clone(); mailDefinition.attachmentReports.clear(); for ( int i = 0; i < attachmentReports.size(); i++ ) { final MasterReport report = (MasterReport) attachmentReports.get( i ); mailDefinition.attachmentReports.add( report.clone() ); } return mailDefinition; } }
MailDefinition implements Serializable, Cloneable { public Object clone() throws CloneNotSupportedException { final MailDefinition mailDefinition = (MailDefinition) super.clone(); mailDefinition.bodyReport = (MasterReport) bodyReport.clone(); mailDefinition.attachmentTypes = (ArrayList) attachmentTypes.clone(); mailDefinition.attachmentReports = (ArrayList) attachmentReports.clone(); mailDefinition.attachmentReports.clear(); for ( int i = 0; i < attachmentReports.size(); i++ ) { final MasterReport report = (MasterReport) attachmentReports.get( i ); mailDefinition.attachmentReports.add( report.clone() ); } return mailDefinition; } MailDefinition();  MailDefinition( final String bodyType, final MasterReport bodyReport ); }
MailDefinition implements Serializable, Cloneable { public Object clone() throws CloneNotSupportedException { final MailDefinition mailDefinition = (MailDefinition) super.clone(); mailDefinition.bodyReport = (MasterReport) bodyReport.clone(); mailDefinition.attachmentTypes = (ArrayList) attachmentTypes.clone(); mailDefinition.attachmentReports = (ArrayList) attachmentReports.clone(); mailDefinition.attachmentReports.clear(); for ( int i = 0; i < attachmentReports.size(); i++ ) { final MasterReport report = (MasterReport) attachmentReports.get( i ); mailDefinition.attachmentReports.add( report.clone() ); } return mailDefinition; } MailDefinition();  MailDefinition( final String bodyType, final MasterReport bodyReport ); ReportEnvironment getReportEnvironment(); ResourceBundleFactory getResourceBundleFactory(); ResourceKey getContextKey(); void setContextKey( final ResourceKey contextKey ); ResourceManager getResourceManager(); void setResourceManager( final ResourceManager resourceManager ); Properties getSessionProperties(); void setSessionProperties( final Properties sessionProperties ); void addStaticHeader( final String name, final String value ); void addFormulaHeader( final String name, final String formula ); void addHeader( final MailHeader header ); MailHeader getHeader( int i ); int getHeaderCount(); MailHeader[] getHeaders(); void addAttachmentReport( final String type, final MasterReport attachmentReport ); String getBodyType(); MasterReport getBodyReport(); void setBodyReport( final String bodyType, final MasterReport bodyReport ); int getAttachmentCount(); MasterReport getAttachmentReport( final int index ); String getAttachmentType( final int index ); void removeAttachment( final int index ); CompoundDataFactory getDataFactory(); ReportParameterValues getParameterValues(); ReportParameterDefinition getParameterDefinition(); void setParameterDefinition( final ReportParameterDefinition parameterDefinition ); String getBurstQuery(); void setBurstQuery( final String burstQuery ); String getRecipientsQuery(); void setRecipientsQuery( final String recipientsQuery ); Object clone(); Authenticator getAuthenticator(); }
MailDefinition implements Serializable, Cloneable { public Object clone() throws CloneNotSupportedException { final MailDefinition mailDefinition = (MailDefinition) super.clone(); mailDefinition.bodyReport = (MasterReport) bodyReport.clone(); mailDefinition.attachmentTypes = (ArrayList) attachmentTypes.clone(); mailDefinition.attachmentReports = (ArrayList) attachmentReports.clone(); mailDefinition.attachmentReports.clear(); for ( int i = 0; i < attachmentReports.size(); i++ ) { final MasterReport report = (MasterReport) attachmentReports.get( i ); mailDefinition.attachmentReports.add( report.clone() ); } return mailDefinition; } MailDefinition();  MailDefinition( final String bodyType, final MasterReport bodyReport ); ReportEnvironment getReportEnvironment(); ResourceBundleFactory getResourceBundleFactory(); ResourceKey getContextKey(); void setContextKey( final ResourceKey contextKey ); ResourceManager getResourceManager(); void setResourceManager( final ResourceManager resourceManager ); Properties getSessionProperties(); void setSessionProperties( final Properties sessionProperties ); void addStaticHeader( final String name, final String value ); void addFormulaHeader( final String name, final String formula ); void addHeader( final MailHeader header ); MailHeader getHeader( int i ); int getHeaderCount(); MailHeader[] getHeaders(); void addAttachmentReport( final String type, final MasterReport attachmentReport ); String getBodyType(); MasterReport getBodyReport(); void setBodyReport( final String bodyType, final MasterReport bodyReport ); int getAttachmentCount(); MasterReport getAttachmentReport( final int index ); String getAttachmentType( final int index ); void removeAttachment( final int index ); CompoundDataFactory getDataFactory(); ReportParameterValues getParameterValues(); ReportParameterDefinition getParameterDefinition(); void setParameterDefinition( final ReportParameterDefinition parameterDefinition ); String getBurstQuery(); void setBurstQuery( final String burstQuery ); String getRecipientsQuery(); void setRecipientsQuery( final String recipientsQuery ); Object clone(); Authenticator getAuthenticator();  }