11/*!
2- * Copyright 2002 - 2017 Webdetails, a Hitachi Vantara company. All rights reserved.
2+ * Copyright 2002 - 2024 Webdetails, a Hitachi Vantara company. All rights reserved.
33 *
44 * This software was developed by Webdetails and is provided under the terms
55 * of the Mozilla Public License, Version 2.0, or any later version. You may not use
2222import org .json .JSONException ;
2323import org .junit .Before ;
2424import org .junit .Test ;
25+ import org .mockito .Mockito ;
2526import org .pentaho .cdf .environment .templater .ITemplater ;
2627import pt .webdetails .cpf .localization .MessageBundlesHelper ;
2728import pt .webdetails .cpf .repository .api .IBasicFile ;
2829import pt .webdetails .cpf .repository .api .IReadAccess ;
2930
30- import static org .mockito .Mockito .*;
31+ import static org .mockito .ArgumentMatchers .any ;
32+ import static org .mockito .ArgumentMatchers .anyBoolean ;
33+ import static org .mockito .ArgumentMatchers .anyInt ;
34+ import static org .mockito .Mockito .doNothing ;
35+ import static org .mockito .Mockito .doReturn ;
36+ import static org .mockito .Mockito .mock ;
37+ import static org .mockito .Mockito .spy ;
38+ import static org .mockito .Mockito .times ;
39+ import static org .mockito .Mockito .verify ;
40+
3141
3242public class CdfHtmlRendererTest extends TestCase {
3343 CdfHtmlRenderer cdfHtmlRenderer ;
@@ -37,7 +47,7 @@ public void setUp() {
3747 cdfHtmlRenderer = spy ( new CdfHtmlRenderer () );
3848 try {
3949 doReturn ( "" ).when ( cdfHtmlRenderer )
40- .getConfiguration ( anyString (), any ( HashMap . class ), anyInt () );
50+ .getConfiguration ( any (), Mockito .< HashMap > any (), anyInt () );
4151 } catch ( JSONException e ) {
4252 e .printStackTrace ();
4353 }
@@ -75,57 +85,57 @@ public void testExecuteRequire() throws Exception {
7585
7686 ITemplater templater = mock ( ITemplater .class );
7787 String intro = "<head></head>" ;
78- doReturn ( intro ).when ( templater ).getTemplateSection ( anyString (), any ( ITemplater .Section .class ) );
88+ doReturn ( intro ).when ( templater ).getTemplateSection ( any (), any ( ITemplater .Section .class ) );
7989 doReturn ( templater ).when ( cdfHtmlRenderer ).getTemplater ();
8090
81- doReturn ( "" ).when ( cdfHtmlRenderer ).updateUserLanguageKey ( anyString () );
82- doReturn ( "" ).when ( cdfHtmlRenderer ).processi18nTags ( anyString (), any ( ArrayList . class ) );
83- doReturn ( "" ).when ( cdfHtmlRenderer ).getDashboardContent ( any ( InputStream . class ), any ( ArrayList . class ) );
91+ doReturn ( "" ).when ( cdfHtmlRenderer ).updateUserLanguageKey ( any () );
92+ doReturn ( "" ).when ( cdfHtmlRenderer ).processi18nTags ( any (), Mockito .< ArrayList > any () );
93+ doReturn ( "" ).when ( cdfHtmlRenderer ).getDashboardContent ( Mockito .< InputStream > any (), Mockito .< ArrayList > any () );
8494
8595 doReturn ( "/public/cdf" ).when ( cdfHtmlRenderer ).getPluginRepositoryDir ();
8696 MessageBundlesHelper mbh = mock ( MessageBundlesHelper .class );
87- doReturn ( intro ).when ( mbh ).replaceParameters ( anyString (), any ( ArrayList . class ) );
88- doReturn ( mbh ).when ( cdfHtmlRenderer ).getMessageBundlesHelper ( anyString () );
97+ doReturn ( intro ).when ( mbh ).replaceParameters ( any (), Mockito .< ArrayList > any () );
98+ doReturn ( mbh ).when ( cdfHtmlRenderer ).getMessageBundlesHelper ( any () );
8999
90100 doNothing ().when ( cdfHtmlRenderer )
91- .getHeadersInternal ( anyString (), any ( HashMap . class ), any ( OutputStream . class ) );
92- doNothing ().when ( cdfHtmlRenderer ).generateContext ( any ( OutputStream . class ), any ( HashMap . class ), anyInt () );
93- doNothing ().when ( cdfHtmlRenderer ).generateStorage ( any ( OutputStream . class ), anyString () );
101+ .getHeadersInternal ( any (), Mockito .< HashMap > any (), Mockito .< OutputStream > any () );
102+ doNothing ().when ( cdfHtmlRenderer ).generateContext ( Mockito .< OutputStream > any (), Mockito .< HashMap > any (), anyInt () );
103+ doNothing ().when ( cdfHtmlRenderer ).generateStorage ( Mockito .< OutputStream > any (), any () );
94104
95105 cdfHtmlRenderer .execute ( outputStream , basicFile , style , messages , parameterMap , user , inactiveInterval ,
96106 /*isRequire*/ true , /*loadTheme*/ false );
97107
98108 verify ( cdfHtmlRenderer , times ( 0 ) )
99- .getHeadersInternal ( anyString (), any ( HashMap . class ), any ( OutputStream . class ) );
100- verify ( cdfHtmlRenderer , times ( 0 ) ).generateContext ( any ( OutputStream . class ), any ( HashMap . class ), anyInt () );
101- verify ( cdfHtmlRenderer , times ( 0 ) ).generateStorage ( any ( OutputStream . class ), anyString () );
102- verify ( cdfHtmlRenderer , times ( 1 ) ).getWebContextHeader ( any ( OutputStream . class ), anyBoolean () );
109+ .getHeadersInternal ( any (), Mockito .< HashMap > any (), Mockito .< OutputStream > any () );
110+ verify ( cdfHtmlRenderer , times ( 0 ) ).generateContext ( Mockito .< OutputStream > any (), Mockito .< HashMap > any (), anyInt () );
111+ verify ( cdfHtmlRenderer , times ( 0 ) ).generateStorage ( Mockito .< OutputStream > any (), any () );
112+ verify ( cdfHtmlRenderer , times ( 1 ) ).getWebContextHeader ( Mockito .< OutputStream > any (), anyBoolean () );
103113
104114 cdfHtmlRenderer .execute ( outputStream , basicFile , style , messages , parameterMap , user , inactiveInterval ,
105115 /*isRequire*/ false , /*loadTheme*/ false );
106116
107117 verify ( cdfHtmlRenderer , times ( 1 ) )
108- .getHeadersInternal ( anyString (), any ( HashMap . class ), any ( OutputStream . class ) );
109- verify ( cdfHtmlRenderer , times ( 1 ) ).generateContext ( any ( OutputStream . class ), any ( HashMap .class ), anyInt () );
110- verify ( cdfHtmlRenderer , times ( 1 ) ).generateStorage ( any ( OutputStream . class ), anyString () );
111- verify ( cdfHtmlRenderer , times ( 1 ) ).getWebContextHeader ( any ( OutputStream . class ), anyBoolean () );
118+ .getHeadersInternal ( any (), Mockito .< HashMap > any (), Mockito .< OutputStream > any () );
119+ verify ( cdfHtmlRenderer , times ( 1 ) ).generateContext ( Mockito .< OutputStream > any (), any ( HashMap .class ), anyInt () );
120+ verify ( cdfHtmlRenderer , times ( 1 ) ).generateStorage ( Mockito .< OutputStream > any (), any () );
121+ verify ( cdfHtmlRenderer , times ( 1 ) ).getWebContextHeader ( Mockito .< OutputStream > any (), anyBoolean () );
112122
113123 cdfHtmlRenderer .execute ( outputStream , basicFile , style , messages , parameterMap , user , inactiveInterval ,
114124 /*isRequire*/ true , /*loadTheme*/ true );
115125
116126 verify ( cdfHtmlRenderer , times ( 1 ) )
117- .getHeadersInternal ( anyString (), any ( HashMap . class ), any ( OutputStream . class ) );
118- verify ( cdfHtmlRenderer , times ( 1 ) ).generateContext ( any ( OutputStream . class ), any ( HashMap .class ), anyInt () );
119- verify ( cdfHtmlRenderer , times ( 1 ) ).generateStorage ( any ( OutputStream . class ), anyString () );
120- verify ( cdfHtmlRenderer , times ( 2 ) ).getWebContextHeader ( any ( OutputStream . class ), anyBoolean () );
127+ .getHeadersInternal ( any (), Mockito .< HashMap > any (), Mockito .< OutputStream > any () );
128+ verify ( cdfHtmlRenderer , times ( 1 ) ).generateContext ( Mockito .< OutputStream > any (), any ( HashMap .class ), anyInt () );
129+ verify ( cdfHtmlRenderer , times ( 1 ) ).generateStorage ( Mockito .< OutputStream > any (), any () );
130+ verify ( cdfHtmlRenderer , times ( 2 ) ).getWebContextHeader ( Mockito .< OutputStream > any (), anyBoolean () );
121131
122132 cdfHtmlRenderer .execute ( outputStream , basicFile , style , messages , parameterMap , user , inactiveInterval ,
123133 /*isRequire*/ false , /*loadTheme*/ true );
124134
125135 verify ( cdfHtmlRenderer , times ( 2 ) )
126- .getHeadersInternal ( anyString (), any ( HashMap . class ), any ( OutputStream . class ) );
127- verify ( cdfHtmlRenderer , times ( 2 ) ).generateContext ( any ( OutputStream . class ), any ( HashMap . class ), anyInt () );
128- verify ( cdfHtmlRenderer , times ( 2 ) ).generateStorage ( any ( OutputStream . class ), anyString () );
129- verify ( cdfHtmlRenderer , times ( 2 ) ).getWebContextHeader ( any ( OutputStream . class ), anyBoolean () );
136+ .getHeadersInternal ( any (), Mockito .< HashMap > any (), Mockito .< OutputStream > any () );
137+ verify ( cdfHtmlRenderer , times ( 2 ) ).generateContext ( Mockito .< OutputStream > any (), Mockito .< HashMap > any (), anyInt () );
138+ verify ( cdfHtmlRenderer , times ( 2 ) ).generateStorage ( Mockito .< OutputStream > any (), any () );
139+ verify ( cdfHtmlRenderer , times ( 2 ) ).getWebContextHeader ( Mockito .< OutputStream > any (), anyBoolean () );
130140 }
131141}
0 commit comments