// ĠCopyright Ġ 2 0 0 0 - 2 0 1 9 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġcom . intellij . openapi . roots . ui . configuration . project Root Ċ Ċ import Ġcom . intellij . openapi . roots .* Ċ import Ġcom . intellij . openapi . roots . impl . libraries . Library Ex Ċ import Ġcom . intellij . openapi . roots . libraries . Library Tables Registrar Ċ import Ġcom . intellij . test Framework . Java Module TestCase Ċ import Ġjunit . framework . TestCase Ċ Ċ class ĠClone Order Entries Test Ġ: ĠJava Module TestCase () Ġ{ ĊĊĠ Ġoverride Ġfun Ġis Run In Write Action (): ĠBoolean Ġ= Ġtrue ĊĊĠ Ġfun Ġ` test Ġcopied Ġj dk Ġand Ġmodule Ġsource `() Ġ{ ĊĠĠĠ Ġval Ġcopy To Mod ifiable Model Ġ= ĠModule Root Manager . getInstance ( create Module (" Copy ĠTo ĠModule ")). modifiable Model ĊĠĠĠ Ġval Ġoriginal Mod ifiable Model Ġ= ĠModule Root Manager . getInstance ( module ). modifiable Model ĊĊĠĠĠ Ġval Ġpath Ġ= Ġoriginal Mod ifiable Model . module . module FilePath ĊĊĠĠĠ Ġ// ĠTested Ġmethods ĊĠĠĠ Ġval Ġbuilder Ġ= ĠModule Structure Configurable . Copied Module Builder ( original Mod ifiable Model , Ġpath , Ġproject ) ĊĠĠĠ Ġbuilder . setup Root Model ( copy To Mod ifiable Model ) ĊĊĠĠĠ Ġoriginal Mod ifiable Model . commit () ĊĠĠĠ Ġcopy To Mod ifiable Model . commit () ĊĊĠĠĠ Ġval Ġoriginal Order Entries Ġ= Ġoriginal Mod ifiable Model . order Entries ĊĠĠĠ Ġval Ġcopied Order Entries Ġ= Ġcopy To Mod ifiable Model . order Entries ĊĊĠĠĠ ĠTestCase . assertEquals ( 2 , Ġcopied Order Entries . size ) ĊĊĠĠĠ Ġval Ġoriginal Sdk Ġ= Ġoriginal Order Entries . filter Is Instance < J dk Order Entry >(). first () ĊĠĠĠ Ġval Ġcopied Sdk Ġ= Ġcopied Order Entries . filter Is Instance < J dk Order Entry >(). first () ĊĊĠĠĠ ĠTestCase . assertEquals ( original Sdk . jdk , Ġcopied Sdk . jdk ) ĊĊĠĠĠ Ġval Ġoriginal Module Source Ġ= Ġoriginal Order Entries . filter Is Instance < Module Source Order Entry >(). first () ĊĠĠĠ Ġval Ġcopied Module Source Ġ= Ġcopied Order Entries . filter Is Instance < Module Source Order Entry >(). first () ĊĊĠĠĠ ĠTestCase . assertEquals ( original Module Source . present able Name , Ġcopied Module Source . present able Name ) ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġcopy Ġmodule Ġwith Ġmodule Ġlibrary `() Ġ{ ĊĠĠĠ Ġval Ġcopy To Mod ifiable Model Ġ= ĠModule Root Manager . getInstance ( create Module (" Copy ĠTo ĠModule ")). modifiable Model ĊĊĠĠĠ Ġval Ġmod ifiable Root Model Ġ= ĠModule Root Manager . getInstance ( module ). modifiable Model ĊĠĠĠ Ġval Ġlibrary Ġ= Ġmod ifiable Root Model . module Library Table . create Library (" My ĠLibrary ") Ġas ĠLibrary Ex ĊĠĠĠ Ġval Ġpath Ġ= Ġmod ifiable Root Model . module . module FilePath ĊĊĠĠĠ Ġ// ĠTested Ġmethods ĊĠĠĠ Ġval Ġbuilder Ġ= ĠModule Structure Configurable . Copied Module Builder ( modifiable Root Model , Ġpath , Ġproject ) ĊĠĠĠ Ġbuilder . setup Root Model ( copy To Mod ifiable Model ) ĊĊĠĠĠ Ġmod ifiable Root Model . commit () ĊĠĠĠ Ġcopy To Mod ifiable Model . commit () ĊĊĠĠĠ Ġval Ġcopied Order Entries Ġ= Ġcopy To Mod ifiable Model . module Library Table . libraries ĊĊĠĠĠ ĠTestCase . assertEquals ( 1 , Ġcopied Order Entries . size ) ĊĊĠĠĠ ĠTestCase . assertNot Same ( library , Ġcopied Order Entries . first ()) ĊĠĠĠ ĠTestCase . assertEquals ( library . name , Ġcopied Order Entries . first (). name ) ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġcopy Ġmodule Ġwith Ġproject Ġlibrary `() Ġ{ ĊĠĠĠ Ġval Ġproject Library Ġ= ĠLibrary Tables Registrar . getInstance (). get Library Table ( project ). create Library (" My ĠLibrary ") ĊĠĠĠ Ġval Ġcopy To Mod ifiable Model Ġ= ĠModule Root Manager . getInstance ( create Module (" My ĠModule ")). modifiable Model ĊĠĠĠ ĠModule Root Modification Util . update Model ( module ) Ġ{ ĊĠĠĠĠĠ Ġit . add Library Entry ( project Library ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġmod ifiable Root Model Ġ= ĠModule Root Manager . getInstance ( module ). modifiable Model ĊĠĠĠ Ġval Ġpath Ġ= Ġmod ifiable Root Model . module . module FilePath ĊĊĠĠĠ Ġ// ĠTested Ġmethods ĊĠĠĠ Ġval Ġbuilder Ġ= ĠModule Structure Configurable . Copied Module Builder ( modifiable Root Model , Ġpath , Ġproject ) ĊĠĠĠ Ġbuilder . setup Root Model ( copy To Mod ifiable Model ) ĊĊĠĠĠ Ġcopy To Mod ifiable Model . commit () ĊĠĠĠ Ġmod ifiable Root Model . commit () ĊĊĠĠĠ Ġval Ġoriginal Order Entries Ġ= Ġmod ifiable Root Model . order Entries . filter Is Instance < Library Order Entry >() ĊĠĠĠ Ġval Ġcopied Order Entries Ġ= Ġcopy To Mod ifiable Model . order Entries . filter Is Instance < Library Order Entry >() ĊĊĠĠĠ ĠTestCase . assertEquals ( 1 , Ġcopied Order Entries . size ) ĊĊĠĠĠ ĠTestCase . assertSame ( project Library , Ġcopied Order Entries . first (). library ) ĊĠĠĠ ĠTestCase . assertNot Same ( original Order Entries . first (), Ġcopied Order Entries . first ()) ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġcopy Ġmodule Ġwith Ġglobal Ġlibrary `() Ġ{ ĊĠĠĠ Ġval Ġcopy To Mod ifiable Model Ġ= ĠModule Root Manager . getInstance ( create Module (" My ĠModule ")). modifiable Model ĊĊĠĠĠ Ġval Ġglobal Library Table Ġ= ĠLibrary Tables Registrar . getInstance (). library Table ĊĠĠĠ Ġval Ġglobal Library Ġ= Ġglobal Library Table . create Library (" My ĠLibrary ") ĊĊĠĠĠ ĠModule Root Modification Util . update Model ( module ) Ġ{ ĊĠĠĠĠĠ Ġit . add Library Entry ( global Library ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġmod ifiable Root Model Ġ= ĠModule Root Manager . getInstance ( module ). modifiable Model ĊĠĠĠ Ġval Ġpath Ġ= Ġmod ifiable Root Model . module . module FilePath ĊĊĠĠĠ Ġ// ĠTested Ġmethods ĊĠĠĠ Ġval Ġbuilder Ġ= ĠModule Structure Configurable . Copied Module Builder ( modifiable Root Model , Ġpath , Ġproject ) ĊĠĠĠ Ġbuilder . setup Root Model ( copy To Mod ifiable Model ) ĊĊĠĠĠ Ġcopy To Mod ifiable Model . commit () ĊĠĠĠ Ġmod ifiable Root Model . commit () ĊĊĠĠĠ Ġval Ġoriginal Order Entries Ġ= Ġmod ifiable Root Model . order Entries . filter Is Instance < Library Order Entry >() ĊĠĠĠ Ġval Ġcopied Order Entries Ġ= Ġcopy To Mod ifiable Model . order Entries . filter Is Instance < Library Order Entry >() ĊĊĠĠĠ ĠTestCase . assertEquals ( 1 , Ġcopied Order Entries . size ) ĊĊĠĠĠ ĠTestCase . assertSame ( global Library , Ġcopied Order Entries . first (). library ) ĊĠĠĠ ĠTestCase . assertNot Same ( original Order Entries . first (), Ġcopied Order Entries . first ()) ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġcopy Ġmodule Ġwith Ġmodule `() Ġ{ ĊĠĠĠ Ġval Ġmain Module Ġ= Ġcreate Module (" Copy ĠTo ĠModel ") ĊĠĠĠ Ġval Ġdep Module Ġ= Ġcreate Module (" My ĠModule ") ĊĠĠĠ Ġval Ġcopy To Mod ifiable Model Ġ= ĠModule Root Manager . getInstance ( main Module ). modifiable Model ĊĊĠĠĠ ĠModule Root Modification Util . update Model ( module ) Ġ{ ĊĠĠĠĠĠ Ġit . add Module Order Entry ( dep Module ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġmod ifiable Root Model Ġ= ĠModule Root Manager . getInstance ( module ). modifiable Model ĊĠĠĠ Ġval Ġpath Ġ= Ġmod ifiable Root Model . module . module FilePath ĊĊĠĠĠ Ġ// ĠTested Ġmethods ĊĠĠĠ Ġval Ġbuilder Ġ= ĠModule Structure Configurable . Copied Module Builder ( modifiable Root Model , Ġpath , Ġproject ) ĊĠĠĠ Ġbuilder . setup Root Model ( copy To Mod ifiable Model ) ĊĊĠĠĠ Ġcopy To Mod ifiable Model . commit () ĊĠĠĠ Ġmod ifiable Root Model . commit () ĊĊĠĠĠ Ġval Ġoriginal Order Entries Ġ= Ġmod ifiable Root Model . order Entries ĊĠĠĠ Ġval Ġcopied Order Entries Ġ= Ġcopy To Mod ifiable Model . order Entries ĊĊĠĠĠ ĠTestCase . assertEquals ( original Order Entries . size , Ġcopied Order Entries . size ) ĊĊĠĠĠ Ġval Ġoriginal Module Ġ= Ġoriginal Order Entries . filter Is Instance < Module Order Entry >(). first () ĊĠĠĠ Ġval Ġcopied Module Ġ= Ġcopied Order Entries . filter Is Instance < Module Order Entry >(). first () ĊĊĠĠĠ ĠTestCase . assertNot Same ( original Module , Ġcopied Module ) ĊĠĠĠ ĠTestCase . assertEquals ( original Module . module , Ġcopied Module . module ) ĊĠĠĠ ĠTestCase . assertEquals ( original Module . scope , Ġcopied Module . scope ) ĊĠ Ġ} Ċ } Ċ