github.com/cloudwego/kitex@v0.9.0/internal/mocks/thrift/test.go (about)

     1  /*
     2   * Copyright 2022 CloudWeGo Authors
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  // Code generated by thriftgo (0.2.1). DO NOT EDIT.
    18  
    19  package thrift
    20  
    21  import (
    22  	"context"
    23  	"fmt"
    24  	"strings"
    25  
    26  	"github.com/apache/thrift/lib/go/thrift"
    27  )
    28  
    29  type MockReq struct {
    30  	Msg     string            `thrift:"Msg,1" json:"Msg"`
    31  	StrMap  map[string]string `thrift:"strMap,2" json:"strMap"`
    32  	StrList []string          `thrift:"strList,3" json:"strList"`
    33  }
    34  
    35  func NewMockReq() *MockReq {
    36  	return &MockReq{}
    37  }
    38  
    39  func (p *MockReq) GetMsg() (v string) {
    40  	return p.Msg
    41  }
    42  
    43  func (p *MockReq) GetStrMap() (v map[string]string) {
    44  	return p.StrMap
    45  }
    46  
    47  func (p *MockReq) GetStrList() (v []string) {
    48  	return p.StrList
    49  }
    50  func (p *MockReq) SetMsg(val string) {
    51  	p.Msg = val
    52  }
    53  func (p *MockReq) SetStrMap(val map[string]string) {
    54  	p.StrMap = val
    55  }
    56  func (p *MockReq) SetStrList(val []string) {
    57  	p.StrList = val
    58  }
    59  
    60  var fieldIDToName_MockReq = map[int16]string{
    61  	1: "Msg",
    62  	2: "strMap",
    63  	3: "strList",
    64  }
    65  
    66  func (p *MockReq) Read(iprot thrift.TProtocol) (err error) {
    67  
    68  	var fieldTypeId thrift.TType
    69  	var fieldId int16
    70  
    71  	if _, err = iprot.ReadStructBegin(); err != nil {
    72  		goto ReadStructBeginError
    73  	}
    74  
    75  	for {
    76  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
    77  		if err != nil {
    78  			goto ReadFieldBeginError
    79  		}
    80  		if fieldTypeId == thrift.STOP {
    81  			break
    82  		}
    83  
    84  		switch fieldId {
    85  		case 1:
    86  			if fieldTypeId == thrift.STRING {
    87  				if err = p.ReadField1(iprot); err != nil {
    88  					goto ReadFieldError
    89  				}
    90  			} else {
    91  				if err = iprot.Skip(fieldTypeId); err != nil {
    92  					goto SkipFieldError
    93  				}
    94  			}
    95  		case 2:
    96  			if fieldTypeId == thrift.MAP {
    97  				if err = p.ReadField2(iprot); err != nil {
    98  					goto ReadFieldError
    99  				}
   100  			} else {
   101  				if err = iprot.Skip(fieldTypeId); err != nil {
   102  					goto SkipFieldError
   103  				}
   104  			}
   105  		case 3:
   106  			if fieldTypeId == thrift.LIST {
   107  				if err = p.ReadField3(iprot); err != nil {
   108  					goto ReadFieldError
   109  				}
   110  			} else {
   111  				if err = iprot.Skip(fieldTypeId); err != nil {
   112  					goto SkipFieldError
   113  				}
   114  			}
   115  		default:
   116  			if err = iprot.Skip(fieldTypeId); err != nil {
   117  				goto SkipFieldError
   118  			}
   119  		}
   120  
   121  		if err = iprot.ReadFieldEnd(); err != nil {
   122  			goto ReadFieldEndError
   123  		}
   124  	}
   125  	if err = iprot.ReadStructEnd(); err != nil {
   126  		goto ReadStructEndError
   127  	}
   128  
   129  	return nil
   130  ReadStructBeginError:
   131  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   132  ReadFieldBeginError:
   133  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   134  ReadFieldError:
   135  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockReq[fieldId]), err)
   136  SkipFieldError:
   137  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   138  
   139  ReadFieldEndError:
   140  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   141  ReadStructEndError:
   142  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   143  }
   144  
   145  func (p *MockReq) ReadField1(iprot thrift.TProtocol) error {
   146  	if v, err := iprot.ReadString(); err != nil {
   147  		return err
   148  	} else {
   149  		p.Msg = v
   150  	}
   151  	return nil
   152  }
   153  
   154  func (p *MockReq) ReadField2(iprot thrift.TProtocol) error {
   155  	_, _, size, err := iprot.ReadMapBegin()
   156  	if err != nil {
   157  		return err
   158  	}
   159  	p.StrMap = make(map[string]string, size)
   160  	for i := 0; i < size; i++ {
   161  		var _key string
   162  		if v, err := iprot.ReadString(); err != nil {
   163  			return err
   164  		} else {
   165  			_key = v
   166  		}
   167  
   168  		var _val string
   169  		if v, err := iprot.ReadString(); err != nil {
   170  			return err
   171  		} else {
   172  			_val = v
   173  		}
   174  
   175  		p.StrMap[_key] = _val
   176  	}
   177  	if err := iprot.ReadMapEnd(); err != nil {
   178  		return err
   179  	}
   180  	return nil
   181  }
   182  
   183  func (p *MockReq) ReadField3(iprot thrift.TProtocol) error {
   184  	_, size, err := iprot.ReadListBegin()
   185  	if err != nil {
   186  		return err
   187  	}
   188  	p.StrList = make([]string, 0, size)
   189  	for i := 0; i < size; i++ {
   190  		var _elem string
   191  		if v, err := iprot.ReadString(); err != nil {
   192  			return err
   193  		} else {
   194  			_elem = v
   195  		}
   196  
   197  		p.StrList = append(p.StrList, _elem)
   198  	}
   199  	if err := iprot.ReadListEnd(); err != nil {
   200  		return err
   201  	}
   202  	return nil
   203  }
   204  
   205  func (p *MockReq) Write(oprot thrift.TProtocol) (err error) {
   206  	var fieldId int16
   207  	if err = oprot.WriteStructBegin("MockReq"); err != nil {
   208  		goto WriteStructBeginError
   209  	}
   210  	if p != nil {
   211  		if err = p.writeField1(oprot); err != nil {
   212  			fieldId = 1
   213  			goto WriteFieldError
   214  		}
   215  		if err = p.writeField2(oprot); err != nil {
   216  			fieldId = 2
   217  			goto WriteFieldError
   218  		}
   219  		if err = p.writeField3(oprot); err != nil {
   220  			fieldId = 3
   221  			goto WriteFieldError
   222  		}
   223  
   224  	}
   225  	if err = oprot.WriteFieldStop(); err != nil {
   226  		goto WriteFieldStopError
   227  	}
   228  	if err = oprot.WriteStructEnd(); err != nil {
   229  		goto WriteStructEndError
   230  	}
   231  	return nil
   232  WriteStructBeginError:
   233  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   234  WriteFieldError:
   235  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   236  WriteFieldStopError:
   237  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   238  WriteStructEndError:
   239  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   240  }
   241  
   242  func (p *MockReq) writeField1(oprot thrift.TProtocol) (err error) {
   243  	if err = oprot.WriteFieldBegin("Msg", thrift.STRING, 1); err != nil {
   244  		goto WriteFieldBeginError
   245  	}
   246  	if err := oprot.WriteString(p.Msg); err != nil {
   247  		return err
   248  	}
   249  	if err = oprot.WriteFieldEnd(); err != nil {
   250  		goto WriteFieldEndError
   251  	}
   252  	return nil
   253  WriteFieldBeginError:
   254  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   255  WriteFieldEndError:
   256  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   257  }
   258  
   259  func (p *MockReq) writeField2(oprot thrift.TProtocol) (err error) {
   260  	if err = oprot.WriteFieldBegin("strMap", thrift.MAP, 2); err != nil {
   261  		goto WriteFieldBeginError
   262  	}
   263  	if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.StrMap)); err != nil {
   264  		return err
   265  	}
   266  	for k, v := range p.StrMap {
   267  
   268  		if err := oprot.WriteString(k); err != nil {
   269  			return err
   270  		}
   271  
   272  		if err := oprot.WriteString(v); err != nil {
   273  			return err
   274  		}
   275  	}
   276  	if err := oprot.WriteMapEnd(); err != nil {
   277  		return err
   278  	}
   279  	if err = oprot.WriteFieldEnd(); err != nil {
   280  		goto WriteFieldEndError
   281  	}
   282  	return nil
   283  WriteFieldBeginError:
   284  	return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
   285  WriteFieldEndError:
   286  	return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
   287  }
   288  
   289  func (p *MockReq) writeField3(oprot thrift.TProtocol) (err error) {
   290  	if err = oprot.WriteFieldBegin("strList", thrift.LIST, 3); err != nil {
   291  		goto WriteFieldBeginError
   292  	}
   293  	if err := oprot.WriteListBegin(thrift.STRING, len(p.StrList)); err != nil {
   294  		return err
   295  	}
   296  	for _, v := range p.StrList {
   297  		if err := oprot.WriteString(v); err != nil {
   298  			return err
   299  		}
   300  	}
   301  	if err := oprot.WriteListEnd(); err != nil {
   302  		return err
   303  	}
   304  	if err = oprot.WriteFieldEnd(); err != nil {
   305  		goto WriteFieldEndError
   306  	}
   307  	return nil
   308  WriteFieldBeginError:
   309  	return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
   310  WriteFieldEndError:
   311  	return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
   312  }
   313  
   314  func (p *MockReq) String() string {
   315  	if p == nil {
   316  		return "<nil>"
   317  	}
   318  	return fmt.Sprintf("MockReq(%+v)", *p)
   319  }
   320  
   321  func (p *MockReq) DeepEqual(ano *MockReq) bool {
   322  	if p == ano {
   323  		return true
   324  	} else if p == nil || ano == nil {
   325  		return false
   326  	}
   327  	if !p.Field1DeepEqual(ano.Msg) {
   328  		return false
   329  	}
   330  	if !p.Field2DeepEqual(ano.StrMap) {
   331  		return false
   332  	}
   333  	if !p.Field3DeepEqual(ano.StrList) {
   334  		return false
   335  	}
   336  	return true
   337  }
   338  
   339  func (p *MockReq) Field1DeepEqual(src string) bool {
   340  
   341  	if strings.Compare(p.Msg, src) != 0 {
   342  		return false
   343  	}
   344  	return true
   345  }
   346  func (p *MockReq) Field2DeepEqual(src map[string]string) bool {
   347  
   348  	if len(p.StrMap) != len(src) {
   349  		return false
   350  	}
   351  	for k, v := range p.StrMap {
   352  		_src := src[k]
   353  		if strings.Compare(v, _src) != 0 {
   354  			return false
   355  		}
   356  	}
   357  	return true
   358  }
   359  func (p *MockReq) Field3DeepEqual(src []string) bool {
   360  
   361  	if len(p.StrList) != len(src) {
   362  		return false
   363  	}
   364  	for i, v := range p.StrList {
   365  		_src := src[i]
   366  		if strings.Compare(v, _src) != 0 {
   367  			return false
   368  		}
   369  	}
   370  	return true
   371  }
   372  
   373  type Exception struct {
   374  	Code int32  `thrift:"code,1" json:"code"`
   375  	Msg  string `thrift:"msg,255" json:"msg"`
   376  }
   377  
   378  func NewException() *Exception {
   379  	return &Exception{}
   380  }
   381  
   382  func (p *Exception) GetCode() (v int32) {
   383  	return p.Code
   384  }
   385  
   386  func (p *Exception) GetMsg() (v string) {
   387  	return p.Msg
   388  }
   389  func (p *Exception) SetCode(val int32) {
   390  	p.Code = val
   391  }
   392  func (p *Exception) SetMsg(val string) {
   393  	p.Msg = val
   394  }
   395  
   396  var fieldIDToName_Exception = map[int16]string{
   397  	1:   "code",
   398  	255: "msg",
   399  }
   400  
   401  func (p *Exception) Read(iprot thrift.TProtocol) (err error) {
   402  
   403  	var fieldTypeId thrift.TType
   404  	var fieldId int16
   405  
   406  	if _, err = iprot.ReadStructBegin(); err != nil {
   407  		goto ReadStructBeginError
   408  	}
   409  
   410  	for {
   411  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   412  		if err != nil {
   413  			goto ReadFieldBeginError
   414  		}
   415  		if fieldTypeId == thrift.STOP {
   416  			break
   417  		}
   418  
   419  		switch fieldId {
   420  		case 1:
   421  			if fieldTypeId == thrift.I32 {
   422  				if err = p.ReadField1(iprot); err != nil {
   423  					goto ReadFieldError
   424  				}
   425  			} else {
   426  				if err = iprot.Skip(fieldTypeId); err != nil {
   427  					goto SkipFieldError
   428  				}
   429  			}
   430  		case 255:
   431  			if fieldTypeId == thrift.STRING {
   432  				if err = p.ReadField255(iprot); err != nil {
   433  					goto ReadFieldError
   434  				}
   435  			} else {
   436  				if err = iprot.Skip(fieldTypeId); err != nil {
   437  					goto SkipFieldError
   438  				}
   439  			}
   440  		default:
   441  			if err = iprot.Skip(fieldTypeId); err != nil {
   442  				goto SkipFieldError
   443  			}
   444  		}
   445  
   446  		if err = iprot.ReadFieldEnd(); err != nil {
   447  			goto ReadFieldEndError
   448  		}
   449  	}
   450  	if err = iprot.ReadStructEnd(); err != nil {
   451  		goto ReadStructEndError
   452  	}
   453  
   454  	return nil
   455  ReadStructBeginError:
   456  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   457  ReadFieldBeginError:
   458  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   459  ReadFieldError:
   460  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Exception[fieldId]), err)
   461  SkipFieldError:
   462  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   463  
   464  ReadFieldEndError:
   465  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   466  ReadStructEndError:
   467  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   468  }
   469  
   470  func (p *Exception) ReadField1(iprot thrift.TProtocol) error {
   471  	if v, err := iprot.ReadI32(); err != nil {
   472  		return err
   473  	} else {
   474  		p.Code = v
   475  	}
   476  	return nil
   477  }
   478  
   479  func (p *Exception) ReadField255(iprot thrift.TProtocol) error {
   480  	if v, err := iprot.ReadString(); err != nil {
   481  		return err
   482  	} else {
   483  		p.Msg = v
   484  	}
   485  	return nil
   486  }
   487  
   488  func (p *Exception) Write(oprot thrift.TProtocol) (err error) {
   489  	var fieldId int16
   490  	if err = oprot.WriteStructBegin("Exception"); err != nil {
   491  		goto WriteStructBeginError
   492  	}
   493  	if p != nil {
   494  		if err = p.writeField1(oprot); err != nil {
   495  			fieldId = 1
   496  			goto WriteFieldError
   497  		}
   498  		if err = p.writeField255(oprot); err != nil {
   499  			fieldId = 255
   500  			goto WriteFieldError
   501  		}
   502  
   503  	}
   504  	if err = oprot.WriteFieldStop(); err != nil {
   505  		goto WriteFieldStopError
   506  	}
   507  	if err = oprot.WriteStructEnd(); err != nil {
   508  		goto WriteStructEndError
   509  	}
   510  	return nil
   511  WriteStructBeginError:
   512  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   513  WriteFieldError:
   514  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   515  WriteFieldStopError:
   516  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   517  WriteStructEndError:
   518  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   519  }
   520  
   521  func (p *Exception) writeField1(oprot thrift.TProtocol) (err error) {
   522  	if err = oprot.WriteFieldBegin("code", thrift.I32, 1); err != nil {
   523  		goto WriteFieldBeginError
   524  	}
   525  	if err := oprot.WriteI32(p.Code); err != nil {
   526  		return err
   527  	}
   528  	if err = oprot.WriteFieldEnd(); err != nil {
   529  		goto WriteFieldEndError
   530  	}
   531  	return nil
   532  WriteFieldBeginError:
   533  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   534  WriteFieldEndError:
   535  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   536  }
   537  
   538  func (p *Exception) writeField255(oprot thrift.TProtocol) (err error) {
   539  	if err = oprot.WriteFieldBegin("msg", thrift.STRING, 255); err != nil {
   540  		goto WriteFieldBeginError
   541  	}
   542  	if err := oprot.WriteString(p.Msg); err != nil {
   543  		return err
   544  	}
   545  	if err = oprot.WriteFieldEnd(); err != nil {
   546  		goto WriteFieldEndError
   547  	}
   548  	return nil
   549  WriteFieldBeginError:
   550  	return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err)
   551  WriteFieldEndError:
   552  	return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err)
   553  }
   554  
   555  func (p *Exception) String() string {
   556  	if p == nil {
   557  		return "<nil>"
   558  	}
   559  	return fmt.Sprintf("Exception(%+v)", *p)
   560  }
   561  func (p *Exception) Error() string {
   562  	return p.String()
   563  }
   564  
   565  func (p *Exception) DeepEqual(ano *Exception) bool {
   566  	if p == ano {
   567  		return true
   568  	} else if p == nil || ano == nil {
   569  		return false
   570  	}
   571  	if !p.Field1DeepEqual(ano.Code) {
   572  		return false
   573  	}
   574  	if !p.Field255DeepEqual(ano.Msg) {
   575  		return false
   576  	}
   577  	return true
   578  }
   579  
   580  func (p *Exception) Field1DeepEqual(src int32) bool {
   581  
   582  	if p.Code != src {
   583  		return false
   584  	}
   585  	return true
   586  }
   587  func (p *Exception) Field255DeepEqual(src string) bool {
   588  
   589  	if strings.Compare(p.Msg, src) != 0 {
   590  		return false
   591  	}
   592  	return true
   593  }
   594  
   595  type Mock interface {
   596  	Test(ctx context.Context, req *MockReq) (r string, err error)
   597  
   598  	ExceptionTest(ctx context.Context, req *MockReq) (r string, err error)
   599  }
   600  
   601  type MockClient struct {
   602  	c thrift.TClient
   603  }
   604  
   605  func NewMockClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *MockClient {
   606  	return &MockClient{
   607  		c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),
   608  	}
   609  }
   610  
   611  func NewMockClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *MockClient {
   612  	return &MockClient{
   613  		c: thrift.NewTStandardClient(iprot, oprot),
   614  	}
   615  }
   616  
   617  func NewMockClient(c thrift.TClient) *MockClient {
   618  	return &MockClient{
   619  		c: c,
   620  	}
   621  }
   622  
   623  func (p *MockClient) Client_() thrift.TClient {
   624  	return p.c
   625  }
   626  
   627  func (p *MockClient) Test(ctx context.Context, req *MockReq) (r string, err error) {
   628  	var _args MockTestArgs
   629  	_args.Req = req
   630  	var _result MockTestResult
   631  	if err = p.Client_().Call(ctx, "Test", &_args, &_result); err != nil {
   632  		return
   633  	}
   634  	return _result.GetSuccess(), nil
   635  }
   636  func (p *MockClient) ExceptionTest(ctx context.Context, req *MockReq) (r string, err error) {
   637  	var _args MockExceptionTestArgs
   638  	_args.Req = req
   639  	var _result MockExceptionTestResult
   640  	if err = p.Client_().Call(ctx, "ExceptionTest", &_args, &_result); err != nil {
   641  		return
   642  	}
   643  	switch {
   644  	case _result.Err != nil:
   645  		return r, _result.Err
   646  	}
   647  	return _result.GetSuccess(), nil
   648  }
   649  
   650  type MockProcessor struct {
   651  	processorMap map[string]thrift.TProcessorFunction
   652  	handler      Mock
   653  }
   654  
   655  func (p *MockProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
   656  	p.processorMap[key] = processor
   657  }
   658  
   659  func (p *MockProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
   660  	processor, ok = p.processorMap[key]
   661  	return processor, ok
   662  }
   663  
   664  func (p *MockProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
   665  	return p.processorMap
   666  }
   667  
   668  func NewMockProcessor(handler Mock) *MockProcessor {
   669  	self := &MockProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
   670  	self.AddToProcessorMap("Test", &mockProcessorTest{handler: handler})
   671  	self.AddToProcessorMap("ExceptionTest", &mockProcessorExceptionTest{handler: handler})
   672  	return self
   673  }
   674  func (p *MockProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   675  	name, _, seqId, err := iprot.ReadMessageBegin()
   676  	if err != nil {
   677  		return false, err
   678  	}
   679  	if processor, ok := p.GetProcessorFunction(name); ok {
   680  		return processor.Process(ctx, seqId, iprot, oprot)
   681  	}
   682  	iprot.Skip(thrift.STRUCT)
   683  	iprot.ReadMessageEnd()
   684  	x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
   685  	oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
   686  	x.Write(oprot)
   687  	oprot.WriteMessageEnd()
   688  	oprot.Flush(ctx)
   689  	return false, x
   690  }
   691  
   692  type mockProcessorTest struct {
   693  	handler Mock
   694  }
   695  
   696  func (p *mockProcessorTest) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   697  	args := MockTestArgs{}
   698  	if err = args.Read(iprot); err != nil {
   699  		iprot.ReadMessageEnd()
   700  		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
   701  		oprot.WriteMessageBegin("Test", thrift.EXCEPTION, seqId)
   702  		x.Write(oprot)
   703  		oprot.WriteMessageEnd()
   704  		oprot.Flush(ctx)
   705  		return false, err
   706  	}
   707  
   708  	iprot.ReadMessageEnd()
   709  	var err2 error
   710  	result := MockTestResult{}
   711  	var retval string
   712  	if retval, err2 = p.handler.Test(ctx, args.Req); err2 != nil {
   713  		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Test: "+err2.Error())
   714  		oprot.WriteMessageBegin("Test", thrift.EXCEPTION, seqId)
   715  		x.Write(oprot)
   716  		oprot.WriteMessageEnd()
   717  		oprot.Flush(ctx)
   718  		return true, err2
   719  	} else {
   720  		result.Success = &retval
   721  	}
   722  	if err2 = oprot.WriteMessageBegin("Test", thrift.REPLY, seqId); err2 != nil {
   723  		err = err2
   724  	}
   725  	if err2 = result.Write(oprot); err == nil && err2 != nil {
   726  		err = err2
   727  	}
   728  	if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
   729  		err = err2
   730  	}
   731  	if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
   732  		err = err2
   733  	}
   734  	if err != nil {
   735  		return
   736  	}
   737  	return true, err
   738  }
   739  
   740  type mockProcessorExceptionTest struct {
   741  	handler Mock
   742  }
   743  
   744  func (p *mockProcessorExceptionTest) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   745  	args := MockExceptionTestArgs{}
   746  	if err = args.Read(iprot); err != nil {
   747  		iprot.ReadMessageEnd()
   748  		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
   749  		oprot.WriteMessageBegin("ExceptionTest", thrift.EXCEPTION, seqId)
   750  		x.Write(oprot)
   751  		oprot.WriteMessageEnd()
   752  		oprot.Flush(ctx)
   753  		return false, err
   754  	}
   755  
   756  	iprot.ReadMessageEnd()
   757  	var err2 error
   758  	result := MockExceptionTestResult{}
   759  	var retval string
   760  	if retval, err2 = p.handler.ExceptionTest(ctx, args.Req); err2 != nil {
   761  		switch v := err2.(type) {
   762  		case *Exception:
   763  			result.Err = v
   764  		default:
   765  			x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing ExceptionTest: "+err2.Error())
   766  			oprot.WriteMessageBegin("ExceptionTest", thrift.EXCEPTION, seqId)
   767  			x.Write(oprot)
   768  			oprot.WriteMessageEnd()
   769  			oprot.Flush(ctx)
   770  			return true, err2
   771  		}
   772  	} else {
   773  		result.Success = &retval
   774  	}
   775  	if err2 = oprot.WriteMessageBegin("ExceptionTest", thrift.REPLY, seqId); err2 != nil {
   776  		err = err2
   777  	}
   778  	if err2 = result.Write(oprot); err == nil && err2 != nil {
   779  		err = err2
   780  	}
   781  	if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
   782  		err = err2
   783  	}
   784  	if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
   785  		err = err2
   786  	}
   787  	if err != nil {
   788  		return
   789  	}
   790  	return true, err
   791  }
   792  
   793  type MockTestArgs struct {
   794  	Req *MockReq `thrift:"req,1" json:"req"`
   795  }
   796  
   797  func NewMockTestArgs() *MockTestArgs {
   798  	return &MockTestArgs{}
   799  }
   800  
   801  var MockTestArgs_Req_DEFAULT *MockReq
   802  
   803  func (p *MockTestArgs) GetReq() (v *MockReq) {
   804  	if !p.IsSetReq() {
   805  		return MockTestArgs_Req_DEFAULT
   806  	}
   807  	return p.Req
   808  }
   809  func (p *MockTestArgs) SetReq(val *MockReq) {
   810  	p.Req = val
   811  }
   812  
   813  func (p *MockTestArgs) GetFirstArgument() (interface{}) {
   814  	return p.Req
   815  }
   816  
   817  var fieldIDToName_MockTestArgs = map[int16]string{
   818  	1: "req",
   819  }
   820  
   821  func (p *MockTestArgs) IsSetReq() bool {
   822  	return p.Req != nil
   823  }
   824  
   825  func (p *MockTestArgs) Read(iprot thrift.TProtocol) (err error) {
   826  
   827  	var fieldTypeId thrift.TType
   828  	var fieldId int16
   829  
   830  	if _, err = iprot.ReadStructBegin(); err != nil {
   831  		goto ReadStructBeginError
   832  	}
   833  
   834  	for {
   835  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   836  		if err != nil {
   837  			goto ReadFieldBeginError
   838  		}
   839  		if fieldTypeId == thrift.STOP {
   840  			break
   841  		}
   842  
   843  		switch fieldId {
   844  		case 1:
   845  			if fieldTypeId == thrift.STRUCT {
   846  				if err = p.ReadField1(iprot); err != nil {
   847  					goto ReadFieldError
   848  				}
   849  			} else {
   850  				if err = iprot.Skip(fieldTypeId); err != nil {
   851  					goto SkipFieldError
   852  				}
   853  			}
   854  		default:
   855  			if err = iprot.Skip(fieldTypeId); err != nil {
   856  				goto SkipFieldError
   857  			}
   858  		}
   859  
   860  		if err = iprot.ReadFieldEnd(); err != nil {
   861  			goto ReadFieldEndError
   862  		}
   863  	}
   864  	if err = iprot.ReadStructEnd(); err != nil {
   865  		goto ReadStructEndError
   866  	}
   867  
   868  	return nil
   869  ReadStructBeginError:
   870  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   871  ReadFieldBeginError:
   872  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   873  ReadFieldError:
   874  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockTestArgs[fieldId]), err)
   875  SkipFieldError:
   876  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   877  
   878  ReadFieldEndError:
   879  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   880  ReadStructEndError:
   881  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   882  }
   883  
   884  func (p *MockTestArgs) ReadField1(iprot thrift.TProtocol) error {
   885  	p.Req = NewMockReq()
   886  	if err := p.Req.Read(iprot); err != nil {
   887  		return err
   888  	}
   889  	return nil
   890  }
   891  
   892  func (p *MockTestArgs) Write(oprot thrift.TProtocol) (err error) {
   893  	var fieldId int16
   894  	if err = oprot.WriteStructBegin("Test_args"); err != nil {
   895  		goto WriteStructBeginError
   896  	}
   897  	if p != nil {
   898  		if err = p.writeField1(oprot); err != nil {
   899  			fieldId = 1
   900  			goto WriteFieldError
   901  		}
   902  
   903  	}
   904  	if err = oprot.WriteFieldStop(); err != nil {
   905  		goto WriteFieldStopError
   906  	}
   907  	if err = oprot.WriteStructEnd(); err != nil {
   908  		goto WriteStructEndError
   909  	}
   910  	return nil
   911  WriteStructBeginError:
   912  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   913  WriteFieldError:
   914  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   915  WriteFieldStopError:
   916  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   917  WriteStructEndError:
   918  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   919  }
   920  
   921  func (p *MockTestArgs) writeField1(oprot thrift.TProtocol) (err error) {
   922  	if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil {
   923  		goto WriteFieldBeginError
   924  	}
   925  	if err := p.Req.Write(oprot); err != nil {
   926  		return err
   927  	}
   928  	if err = oprot.WriteFieldEnd(); err != nil {
   929  		goto WriteFieldEndError
   930  	}
   931  	return nil
   932  WriteFieldBeginError:
   933  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   934  WriteFieldEndError:
   935  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   936  }
   937  
   938  func (p *MockTestArgs) String() string {
   939  	if p == nil {
   940  		return "<nil>"
   941  	}
   942  	return fmt.Sprintf("MockTestArgs(%+v)", *p)
   943  }
   944  
   945  func (p *MockTestArgs) DeepEqual(ano *MockTestArgs) bool {
   946  	if p == ano {
   947  		return true
   948  	} else if p == nil || ano == nil {
   949  		return false
   950  	}
   951  	if !p.Field1DeepEqual(ano.Req) {
   952  		return false
   953  	}
   954  	return true
   955  }
   956  
   957  func (p *MockTestArgs) Field1DeepEqual(src *MockReq) bool {
   958  
   959  	if !p.Req.DeepEqual(src) {
   960  		return false
   961  	}
   962  	return true
   963  }
   964  
   965  type MockTestResult struct {
   966  	Success *string `thrift:"success,0,optional" json:"success,omitempty"`
   967  }
   968  
   969  func NewMockTestResult() *MockTestResult {
   970  	return &MockTestResult{}
   971  }
   972  
   973  var MockTestResult_Success_DEFAULT string
   974  
   975  func (p *MockTestResult) GetSuccess() (v string) {
   976  	if !p.IsSetSuccess() {
   977  		return MockTestResult_Success_DEFAULT
   978  	}
   979  	return *p.Success
   980  }
   981  func (p *MockTestResult) SetSuccess(x interface{}) {
   982  	p.Success = x.(*string)
   983  }
   984  
   985  func (p *MockTestResult) GetResult() interface{} {
   986  	return p.Success
   987  }
   988  
   989  var fieldIDToName_MockTestResult = map[int16]string{
   990  	0: "success",
   991  }
   992  
   993  func (p *MockTestResult) IsSetSuccess() bool {
   994  	return p.Success != nil
   995  }
   996  
   997  func (p *MockTestResult) Read(iprot thrift.TProtocol) (err error) {
   998  
   999  	var fieldTypeId thrift.TType
  1000  	var fieldId int16
  1001  
  1002  	if _, err = iprot.ReadStructBegin(); err != nil {
  1003  		goto ReadStructBeginError
  1004  	}
  1005  
  1006  	for {
  1007  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
  1008  		if err != nil {
  1009  			goto ReadFieldBeginError
  1010  		}
  1011  		if fieldTypeId == thrift.STOP {
  1012  			break
  1013  		}
  1014  
  1015  		switch fieldId {
  1016  		case 0:
  1017  			if fieldTypeId == thrift.STRING {
  1018  				if err = p.ReadField0(iprot); err != nil {
  1019  					goto ReadFieldError
  1020  				}
  1021  			} else {
  1022  				if err = iprot.Skip(fieldTypeId); err != nil {
  1023  					goto SkipFieldError
  1024  				}
  1025  			}
  1026  		default:
  1027  			if err = iprot.Skip(fieldTypeId); err != nil {
  1028  				goto SkipFieldError
  1029  			}
  1030  		}
  1031  
  1032  		if err = iprot.ReadFieldEnd(); err != nil {
  1033  			goto ReadFieldEndError
  1034  		}
  1035  	}
  1036  	if err = iprot.ReadStructEnd(); err != nil {
  1037  		goto ReadStructEndError
  1038  	}
  1039  
  1040  	return nil
  1041  ReadStructBeginError:
  1042  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
  1043  ReadFieldBeginError:
  1044  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
  1045  ReadFieldError:
  1046  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockTestResult[fieldId]), err)
  1047  SkipFieldError:
  1048  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
  1049  
  1050  ReadFieldEndError:
  1051  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
  1052  ReadStructEndError:
  1053  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  1054  }
  1055  
  1056  func (p *MockTestResult) ReadField0(iprot thrift.TProtocol) error {
  1057  	if v, err := iprot.ReadString(); err != nil {
  1058  		return err
  1059  	} else {
  1060  		p.Success = &v
  1061  	}
  1062  	return nil
  1063  }
  1064  
  1065  func (p *MockTestResult) Write(oprot thrift.TProtocol) (err error) {
  1066  	var fieldId int16
  1067  	if err = oprot.WriteStructBegin("Test_result"); err != nil {
  1068  		goto WriteStructBeginError
  1069  	}
  1070  	if p != nil {
  1071  		if err = p.writeField0(oprot); err != nil {
  1072  			fieldId = 0
  1073  			goto WriteFieldError
  1074  		}
  1075  
  1076  	}
  1077  	if err = oprot.WriteFieldStop(); err != nil {
  1078  		goto WriteFieldStopError
  1079  	}
  1080  	if err = oprot.WriteStructEnd(); err != nil {
  1081  		goto WriteStructEndError
  1082  	}
  1083  	return nil
  1084  WriteStructBeginError:
  1085  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  1086  WriteFieldError:
  1087  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
  1088  WriteFieldStopError:
  1089  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
  1090  WriteStructEndError:
  1091  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
  1092  }
  1093  
  1094  func (p *MockTestResult) writeField0(oprot thrift.TProtocol) (err error) {
  1095  	if p.IsSetSuccess() {
  1096  		if err = oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil {
  1097  			goto WriteFieldBeginError
  1098  		}
  1099  		if err := oprot.WriteString(*p.Success); err != nil {
  1100  			return err
  1101  		}
  1102  		if err = oprot.WriteFieldEnd(); err != nil {
  1103  			goto WriteFieldEndError
  1104  		}
  1105  	}
  1106  	return nil
  1107  WriteFieldBeginError:
  1108  	return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err)
  1109  WriteFieldEndError:
  1110  	return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err)
  1111  }
  1112  
  1113  func (p *MockTestResult) String() string {
  1114  	if p == nil {
  1115  		return "<nil>"
  1116  	}
  1117  	return fmt.Sprintf("MockTestResult(%+v)", *p)
  1118  }
  1119  
  1120  func (p *MockTestResult) DeepEqual(ano *MockTestResult) bool {
  1121  	if p == ano {
  1122  		return true
  1123  	} else if p == nil || ano == nil {
  1124  		return false
  1125  	}
  1126  	if !p.Field0DeepEqual(ano.Success) {
  1127  		return false
  1128  	}
  1129  	return true
  1130  }
  1131  
  1132  func (p *MockTestResult) Field0DeepEqual(src *string) bool {
  1133  
  1134  	if p.Success == src {
  1135  		return true
  1136  	} else if p.Success == nil || src == nil {
  1137  		return false
  1138  	}
  1139  	if strings.Compare(*p.Success, *src) != 0 {
  1140  		return false
  1141  	}
  1142  	return true
  1143  }
  1144  
  1145  type MockExceptionTestArgs struct {
  1146  	Req *MockReq `thrift:"req,1" json:"req"`
  1147  }
  1148  
  1149  func NewMockExceptionTestArgs() *MockExceptionTestArgs {
  1150  	return &MockExceptionTestArgs{}
  1151  }
  1152  
  1153  var MockExceptionTestArgs_Req_DEFAULT *MockReq
  1154  
  1155  func (p *MockExceptionTestArgs) GetReq() (v *MockReq) {
  1156  	if !p.IsSetReq() {
  1157  		return MockExceptionTestArgs_Req_DEFAULT
  1158  	}
  1159  	return p.Req
  1160  }
  1161  func (p *MockExceptionTestArgs) SetReq(val *MockReq) {
  1162  	p.Req = val
  1163  }
  1164  
  1165  var fieldIDToName_MockExceptionTestArgs = map[int16]string{
  1166  	1: "req",
  1167  }
  1168  
  1169  func (p *MockExceptionTestArgs) IsSetReq() bool {
  1170  	return p.Req != nil
  1171  }
  1172  
  1173  func (p *MockExceptionTestArgs) Read(iprot thrift.TProtocol) (err error) {
  1174  
  1175  	var fieldTypeId thrift.TType
  1176  	var fieldId int16
  1177  
  1178  	if _, err = iprot.ReadStructBegin(); err != nil {
  1179  		goto ReadStructBeginError
  1180  	}
  1181  
  1182  	for {
  1183  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
  1184  		if err != nil {
  1185  			goto ReadFieldBeginError
  1186  		}
  1187  		if fieldTypeId == thrift.STOP {
  1188  			break
  1189  		}
  1190  
  1191  		switch fieldId {
  1192  		case 1:
  1193  			if fieldTypeId == thrift.STRUCT {
  1194  				if err = p.ReadField1(iprot); err != nil {
  1195  					goto ReadFieldError
  1196  				}
  1197  			} else {
  1198  				if err = iprot.Skip(fieldTypeId); err != nil {
  1199  					goto SkipFieldError
  1200  				}
  1201  			}
  1202  		default:
  1203  			if err = iprot.Skip(fieldTypeId); err != nil {
  1204  				goto SkipFieldError
  1205  			}
  1206  		}
  1207  
  1208  		if err = iprot.ReadFieldEnd(); err != nil {
  1209  			goto ReadFieldEndError
  1210  		}
  1211  	}
  1212  	if err = iprot.ReadStructEnd(); err != nil {
  1213  		goto ReadStructEndError
  1214  	}
  1215  
  1216  	return nil
  1217  ReadStructBeginError:
  1218  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
  1219  ReadFieldBeginError:
  1220  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
  1221  ReadFieldError:
  1222  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockExceptionTestArgs[fieldId]), err)
  1223  SkipFieldError:
  1224  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
  1225  
  1226  ReadFieldEndError:
  1227  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
  1228  ReadStructEndError:
  1229  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  1230  }
  1231  
  1232  func (p *MockExceptionTestArgs) ReadField1(iprot thrift.TProtocol) error {
  1233  	p.Req = NewMockReq()
  1234  	if err := p.Req.Read(iprot); err != nil {
  1235  		return err
  1236  	}
  1237  	return nil
  1238  }
  1239  
  1240  func (p *MockExceptionTestArgs) Write(oprot thrift.TProtocol) (err error) {
  1241  	var fieldId int16
  1242  	if err = oprot.WriteStructBegin("ExceptionTest_args"); err != nil {
  1243  		goto WriteStructBeginError
  1244  	}
  1245  	if p != nil {
  1246  		if err = p.writeField1(oprot); err != nil {
  1247  			fieldId = 1
  1248  			goto WriteFieldError
  1249  		}
  1250  
  1251  	}
  1252  	if err = oprot.WriteFieldStop(); err != nil {
  1253  		goto WriteFieldStopError
  1254  	}
  1255  	if err = oprot.WriteStructEnd(); err != nil {
  1256  		goto WriteStructEndError
  1257  	}
  1258  	return nil
  1259  WriteStructBeginError:
  1260  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  1261  WriteFieldError:
  1262  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
  1263  WriteFieldStopError:
  1264  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
  1265  WriteStructEndError:
  1266  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
  1267  }
  1268  
  1269  func (p *MockExceptionTestArgs) writeField1(oprot thrift.TProtocol) (err error) {
  1270  	if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil {
  1271  		goto WriteFieldBeginError
  1272  	}
  1273  	if err := p.Req.Write(oprot); err != nil {
  1274  		return err
  1275  	}
  1276  	if err = oprot.WriteFieldEnd(); err != nil {
  1277  		goto WriteFieldEndError
  1278  	}
  1279  	return nil
  1280  WriteFieldBeginError:
  1281  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
  1282  WriteFieldEndError:
  1283  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
  1284  }
  1285  
  1286  func (p *MockExceptionTestArgs) String() string {
  1287  	if p == nil {
  1288  		return "<nil>"
  1289  	}
  1290  	return fmt.Sprintf("MockExceptionTestArgs(%+v)", *p)
  1291  }
  1292  
  1293  func (p *MockExceptionTestArgs) DeepEqual(ano *MockExceptionTestArgs) bool {
  1294  	if p == ano {
  1295  		return true
  1296  	} else if p == nil || ano == nil {
  1297  		return false
  1298  	}
  1299  	if !p.Field1DeepEqual(ano.Req) {
  1300  		return false
  1301  	}
  1302  	return true
  1303  }
  1304  
  1305  func (p *MockExceptionTestArgs) Field1DeepEqual(src *MockReq) bool {
  1306  
  1307  	if !p.Req.DeepEqual(src) {
  1308  		return false
  1309  	}
  1310  	return true
  1311  }
  1312  
  1313  type MockExceptionTestResult struct {
  1314  	Success *string    `thrift:"success,0,optional" json:"success,omitempty"`
  1315  	Err     *Exception `thrift:"err,1,optional" json:"err,omitempty"`
  1316  }
  1317  
  1318  func NewMockExceptionTestResult() *MockExceptionTestResult {
  1319  	return &MockExceptionTestResult{}
  1320  }
  1321  
  1322  var MockExceptionTestResult_Success_DEFAULT string
  1323  
  1324  func (p *MockExceptionTestResult) GetSuccess() (v string) {
  1325  	if !p.IsSetSuccess() {
  1326  		return MockExceptionTestResult_Success_DEFAULT
  1327  	}
  1328  	return *p.Success
  1329  }
  1330  
  1331  var MockExceptionTestResult_Err_DEFAULT *Exception
  1332  
  1333  func (p *MockExceptionTestResult) GetErr() (v *Exception) {
  1334  	if !p.IsSetErr() {
  1335  		return MockExceptionTestResult_Err_DEFAULT
  1336  	}
  1337  	return p.Err
  1338  }
  1339  func (p *MockExceptionTestResult) SetSuccess(x interface{}) {
  1340  	p.Success = x.(*string)
  1341  }
  1342  func (p *MockExceptionTestResult) SetErr(val *Exception) {
  1343  	p.Err = val
  1344  }
  1345  
  1346  var fieldIDToName_MockExceptionTestResult = map[int16]string{
  1347  	0: "success",
  1348  	1: "err",
  1349  }
  1350  
  1351  func (p *MockExceptionTestResult) IsSetSuccess() bool {
  1352  	return p.Success != nil
  1353  }
  1354  
  1355  func (p *MockExceptionTestResult) IsSetErr() bool {
  1356  	return p.Err != nil
  1357  }
  1358  
  1359  func (p *MockExceptionTestResult) Read(iprot thrift.TProtocol) (err error) {
  1360  
  1361  	var fieldTypeId thrift.TType
  1362  	var fieldId int16
  1363  
  1364  	if _, err = iprot.ReadStructBegin(); err != nil {
  1365  		goto ReadStructBeginError
  1366  	}
  1367  
  1368  	for {
  1369  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
  1370  		if err != nil {
  1371  			goto ReadFieldBeginError
  1372  		}
  1373  		if fieldTypeId == thrift.STOP {
  1374  			break
  1375  		}
  1376  
  1377  		switch fieldId {
  1378  		case 0:
  1379  			if fieldTypeId == thrift.STRING {
  1380  				if err = p.ReadField0(iprot); err != nil {
  1381  					goto ReadFieldError
  1382  				}
  1383  			} else {
  1384  				if err = iprot.Skip(fieldTypeId); err != nil {
  1385  					goto SkipFieldError
  1386  				}
  1387  			}
  1388  		case 1:
  1389  			if fieldTypeId == thrift.STRUCT {
  1390  				if err = p.ReadField1(iprot); err != nil {
  1391  					goto ReadFieldError
  1392  				}
  1393  			} else {
  1394  				if err = iprot.Skip(fieldTypeId); err != nil {
  1395  					goto SkipFieldError
  1396  				}
  1397  			}
  1398  		default:
  1399  			if err = iprot.Skip(fieldTypeId); err != nil {
  1400  				goto SkipFieldError
  1401  			}
  1402  		}
  1403  
  1404  		if err = iprot.ReadFieldEnd(); err != nil {
  1405  			goto ReadFieldEndError
  1406  		}
  1407  	}
  1408  	if err = iprot.ReadStructEnd(); err != nil {
  1409  		goto ReadStructEndError
  1410  	}
  1411  
  1412  	return nil
  1413  ReadStructBeginError:
  1414  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
  1415  ReadFieldBeginError:
  1416  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
  1417  ReadFieldError:
  1418  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_MockExceptionTestResult[fieldId]), err)
  1419  SkipFieldError:
  1420  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
  1421  
  1422  ReadFieldEndError:
  1423  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
  1424  ReadStructEndError:
  1425  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  1426  }
  1427  
  1428  func (p *MockExceptionTestResult) ReadField0(iprot thrift.TProtocol) error {
  1429  	if v, err := iprot.ReadString(); err != nil {
  1430  		return err
  1431  	} else {
  1432  		p.Success = &v
  1433  	}
  1434  	return nil
  1435  }
  1436  
  1437  func (p *MockExceptionTestResult) ReadField1(iprot thrift.TProtocol) error {
  1438  	p.Err = NewException()
  1439  	if err := p.Err.Read(iprot); err != nil {
  1440  		return err
  1441  	}
  1442  	return nil
  1443  }
  1444  
  1445  func (p *MockExceptionTestResult) Write(oprot thrift.TProtocol) (err error) {
  1446  	var fieldId int16
  1447  	if err = oprot.WriteStructBegin("ExceptionTest_result"); err != nil {
  1448  		goto WriteStructBeginError
  1449  	}
  1450  	if p != nil {
  1451  		if err = p.writeField0(oprot); err != nil {
  1452  			fieldId = 0
  1453  			goto WriteFieldError
  1454  		}
  1455  		if err = p.writeField1(oprot); err != nil {
  1456  			fieldId = 1
  1457  			goto WriteFieldError
  1458  		}
  1459  
  1460  	}
  1461  	if err = oprot.WriteFieldStop(); err != nil {
  1462  		goto WriteFieldStopError
  1463  	}
  1464  	if err = oprot.WriteStructEnd(); err != nil {
  1465  		goto WriteStructEndError
  1466  	}
  1467  	return nil
  1468  WriteStructBeginError:
  1469  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  1470  WriteFieldError:
  1471  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
  1472  WriteFieldStopError:
  1473  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
  1474  WriteStructEndError:
  1475  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
  1476  }
  1477  
  1478  func (p *MockExceptionTestResult) writeField0(oprot thrift.TProtocol) (err error) {
  1479  	if p.IsSetSuccess() {
  1480  		if err = oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil {
  1481  			goto WriteFieldBeginError
  1482  		}
  1483  		if err := oprot.WriteString(*p.Success); err != nil {
  1484  			return err
  1485  		}
  1486  		if err = oprot.WriteFieldEnd(); err != nil {
  1487  			goto WriteFieldEndError
  1488  		}
  1489  	}
  1490  	return nil
  1491  WriteFieldBeginError:
  1492  	return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err)
  1493  WriteFieldEndError:
  1494  	return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err)
  1495  }
  1496  
  1497  func (p *MockExceptionTestResult) writeField1(oprot thrift.TProtocol) (err error) {
  1498  	if p.IsSetErr() {
  1499  		if err = oprot.WriteFieldBegin("err", thrift.STRUCT, 1); err != nil {
  1500  			goto WriteFieldBeginError
  1501  		}
  1502  		if err := p.Err.Write(oprot); err != nil {
  1503  			return err
  1504  		}
  1505  		if err = oprot.WriteFieldEnd(); err != nil {
  1506  			goto WriteFieldEndError
  1507  		}
  1508  	}
  1509  	return nil
  1510  WriteFieldBeginError:
  1511  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
  1512  WriteFieldEndError:
  1513  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
  1514  }
  1515  
  1516  func (p *MockExceptionTestResult) String() string {
  1517  	if p == nil {
  1518  		return "<nil>"
  1519  	}
  1520  	return fmt.Sprintf("MockExceptionTestResult(%+v)", *p)
  1521  }
  1522  
  1523  func (p *MockExceptionTestResult) DeepEqual(ano *MockExceptionTestResult) bool {
  1524  	if p == ano {
  1525  		return true
  1526  	} else if p == nil || ano == nil {
  1527  		return false
  1528  	}
  1529  	if !p.Field0DeepEqual(ano.Success) {
  1530  		return false
  1531  	}
  1532  	if !p.Field1DeepEqual(ano.Err) {
  1533  		return false
  1534  	}
  1535  	return true
  1536  }
  1537  
  1538  func (p *MockExceptionTestResult) Field0DeepEqual(src *string) bool {
  1539  
  1540  	if p.Success == src {
  1541  		return true
  1542  	} else if p.Success == nil || src == nil {
  1543  		return false
  1544  	}
  1545  	if strings.Compare(*p.Success, *src) != 0 {
  1546  		return false
  1547  	}
  1548  	return true
  1549  }
  1550  func (p *MockExceptionTestResult) Field1DeepEqual(src *Exception) bool {
  1551  
  1552  	if !p.Err.DeepEqual(src) {
  1553  		return false
  1554  	}
  1555  	return true
  1556  }