11/*
2- * Copyright (C) 2004-2019 , GoodData(R) Corporation. All rights reserved.
2+ * Copyright (C) 2004-2021 , GoodData(R) Corporation. All rights reserved.
33 * This source code is licensed under the BSD-style license found in the
44 * LICENSE.txt file in the root directory of this source tree.
55 */
3838import static com .gooddata .sdk .model .md .Restriction .identifier ;
3939import static com .gooddata .sdk .model .md .report .MetricGroup .METRIC_GROUP ;
4040import static java .util .Arrays .asList ;
41+ import static java .util .Collections .singletonList ;
4142import static org .hamcrest .MatcherAssert .assertThat ;
4243import static org .hamcrest .Matchers .empty ;
4344import static org .hamcrest .Matchers .hasItems ;
5253public class MetadataServiceAT extends AbstractGoodDataAT {
5354
5455 @ Test (groups = "md" , dependsOnGroups = "model" )
55- public void getObjs () throws Exception {
56+ public void getObjs () {
5657 final MetadataService md = gd .getMetadataService ();
5758
5859 fact = md .getObjUri (project , Fact .class , identifier ("fact.person.shoesize" ));
5960 attr = md .getObj (project , Attribute .class , identifier ("attr.person.department" ));
6061 }
6162
6263 @ Test (groups = "md" , dependsOnMethods = "getObjs" )
63- public void updateObj () throws Exception {
64+ public void updateObj () {
6465 final MetadataService md = gd .getMetadataService ();
6566
6667 attr .setSummary ("Changed person department" );
@@ -70,7 +71,7 @@ public void updateObj() throws Exception {
7071 }
7172
7273 @ Test (groups = "md" , dependsOnMethods = "getObjs" )
73- public void createMetric () throws Exception {
74+ public void createMetric () {
7475 final MetadataService md = gd .getMetadataService ();
7576 final Metric create = new Metric ("Avg shoe size" , "SELECT AVG([" + fact + "])" , "#,##0" );
7677 create .setIdentifier ("metric.avgshoesize" );
@@ -79,12 +80,12 @@ public void createMetric() throws Exception {
7980 }
8081
8182 @ Test (groups = "md" , dependsOnMethods = "createMetric" )
82- public void createReport () throws Exception {
83+ public void createReport () {
8384 final MetadataService md = gd .getMetadataService ();
8485
8586 reportDefinition = md .createObj (project , GridReportDefinitionContent .create (
8687 "Department avg shoe size" ,
87- asList (METRIC_GROUP ),
88+ singletonList (METRIC_GROUP ),
8889 asList (new AttributeInGrid (attr .getDefaultDisplayForm ())),
8990 asList (new MetricElement (metric , "Avg shoe size" )),
9091 asList (new Filter ("(SELECT [" + metric .getUri () + "]) >= 0" ))
@@ -93,7 +94,7 @@ public void createReport() throws Exception {
9394 }
9495
9596 @ Test (groups = "md" , dependsOnGroups = "model" )
96- public void createDashboardEmpty () throws Exception {
97+ public void createDashboardEmpty () {
9798 dashboard = gd .getMetadataService ().createObj (project , new ProjectDashboard ("My Dashboard" , new Tab ("My Tab" )));
9899
99100 assertThat (dashboard .getTitle (), is ("My Dashboard" ));
@@ -139,7 +140,7 @@ public void usedByBatch() {
139140 }
140141
141142 @ Test (groups = "md" , dependsOnGroups = "model" )
142- public void getObjsByUris () throws Exception {
143+ public void getObjsByUris () {
143144 final MetadataService md = gd .getMetadataService ();
144145
145146 final Map <String , String > uris =
@@ -154,7 +155,7 @@ public void getObjsByUris() throws Exception {
154155 }
155156
156157 @ Test (groups = "md" , dependsOnMethods = "createReport" )
157- public void createScheduledMail () throws Exception {
158+ public void createScheduledMail () {
158159 final MetadataService md = gd .getMetadataService ();
159160
160161 scheduledMail = md .createObj (project ,
@@ -172,7 +173,7 @@ public void createScheduledMail() throws Exception {
172173 }
173174
174175 @ Test (groups = "md" , dependsOnMethods = "createScheduledMail" )
175- public void retrieveScheduledMail () throws Exception {
176+ public void retrieveScheduledMail () {
176177 final MetadataService md = gd .getMetadataService ();
177178 Collection <Entry > result = md .find (project , ScheduledMail .class );
178179 assertThat (result , hasSize (1 ));
@@ -183,7 +184,7 @@ public void retrieveScheduledMail() throws Exception {
183184 }
184185
185186 @ Test (groups = "md" , dependsOnMethods = "retrieveScheduledMail" )
186- public void removeScheduledMail () throws Exception {
187+ public void removeScheduledMail () {
187188 final MetadataService metadataService = gd .getMetadataService ();
188189 metadataService .removeObj (scheduledMail );
189190 }
@@ -192,30 +193,49 @@ public void removeScheduledMail() throws Exception {
192193 public void identifiersToUri () {
193194 final MetadataService metadataService = gd .getMetadataService ();
194195 final Map <String , String > idsToUris =
195- metadataService .identifiersToUris (project , asList ("attr.person.department" ));
196+ metadataService .identifiersToUris (project , singletonList ("attr.person.department" ));
196197 assertThat (idsToUris .entrySet (), hasSize (1 ));
197198 final Attribute attribute = metadataService .getObjByUri (idsToUris .get ("attr.person.department" ), Attribute .class );
198199 assertThat (attribute .getIdentifier (), is ("attr.person.department" ));
199200 }
200201
201202 @ Test (dependsOnGroups = "export" , dependsOnMethods = {"usedBy" , "usedByBatch" })
202- public void removeReport () throws Exception {
203+ public void removeReport () {
203204 final MetadataService metadataService = gd .getMetadataService ();
204205 metadataService .removeObj (report );
205206 }
206207
207208 @ Test (dependsOnMethods = {"removeReport" , "removeScheduledMail" })
208- public void removeDefinition () throws Exception {
209+ public void removeDefinition () {
209210 final MetadataService metadataService = gd .getMetadataService ();
210211 metadataService .removeObj (reportDefinition );
211212 }
212213
213214 @ Test (groups = "mdAfterLoad" , dependsOnGroups = {"model" , "dataset" }, dependsOnMethods = "getObjs" )
214- public void getAttributeElements () throws Exception {
215+ public void getAttributeElements () {
215216 final List <AttributeElement > elements = gd .getMetadataService ().getAttributeElements (attr );
216217 assertThat ("there should be 2 elements" , elements , hasSize (2 ));
217218 final Set <String > titles = new HashSet <>(elements .size ());
218219 titles .addAll (elements .stream ().map (AttributeElement ::getTitle ).collect (Collectors .toList ()));
219220 assertThat (titles , hasItems ("DevOps" , "HR" ));
220221 }
222+
223+ @ Test (groups = "md" , dependsOnGroups = "project" )
224+ public void getTimezone () {
225+ final MetadataService md = gd .getMetadataService ();
226+
227+ final String tz = md .getTimezone (project );
228+ assertThat (tz , is ("America/Los_Angeles" ));
229+ }
230+
231+ @ Test (groups = "md" , dependsOnMethods = "getTimezone" )
232+ public void setTimezone () {
233+ final MetadataService md = gd .getMetadataService ();
234+
235+ md .setTimezone (project , "UTC" );
236+
237+ final String tz = md .getTimezone (project );
238+ assertThat (tz , is ("UTC" ));
239+ }
240+
221241}
0 commit comments