### Question:
MetadataService extends PentahoBase { @GET @Path( "/getDatasourcePermissions" ) @Produces( { APPLICATION_JSON } ) public String getDatasourcePermissions() { boolean canEdit = hasManageAccess(); boolean canView = hasViewAccess(); if ( canEdit ) { return "EDIT"; } else if ( canView ) { return "VIEW"; } return "NONE"; } MetadataService(); @GET @Path( "/getDatasourcePermissions" ) @Produces( { APPLICATION_JSON } ) String getDatasourcePermissions(); ModelInfo[] listBusinessModels( String domainName ); String listBusinessModelsJson( String domainName ); Model loadModel( String domainId, String modelId ); String loadModelJson( String domainId, String modelId ); MarshallableResultSet doQuery( Query query, Integer rowLimit ); MarshallableResultSet doXmlQuery( String xml, Integer rowLimit ); String doXmlQueryToJson( String xml, int rowLimit ); String doXmlQueryToCdaJson( String xml, int rowLimit ); MarshallableResultSet doJsonQuery( String json, Integer rowLimit ); String doJsonQueryToJson( String json, int rowLimit ); String doJsonQueryToCdaJson( String json, int rowLimit ); @Override Log getLogger();  }### Answer:
@Test public void testGetDatasourcePermissions() { when( metadataService.getDatasourcePermissions() ).thenCallRealMethod(); when( metadataService.hasViewAccess() ).thenReturn( true ); Assert.assertThat( metadataService.getDatasourcePermissions(), is( "VIEW" ) ); when( metadataService.hasManageAccess() ).thenReturn( true ); Assert.assertThat( metadataService.getDatasourcePermissions(), is( "EDIT" ) ); when( metadataService.hasViewAccess() ).thenReturn( false ); when( metadataService.hasManageAccess() ).thenReturn( false ); Assert.assertThat( metadataService.getDatasourcePermissions(), is( "NONE" ) ); }