0% found this document useful (0 votes)
0 views

Mobile connection Java code

The document is a Java test class for a mobile service application, which includes various test methods to validate connection types and view mobile details. It utilizes JUnit for testing and contains methods to assert the validity of mobile service connections based on different criteria. The class initializes a list of mobile objects and tests their functionalities, ensuring that exceptions are thrown for invalid inputs.

Uploaded by

qoyhuda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Mobile connection Java code

The document is a Java test class for a mobile service application, which includes various test methods to validate connection types and view mobile details. It utilizes JUnit for testing and contains methods to assert the validity of mobile service connections based on different criteria. The class initializes a list of mobile objects and tests their functionalities, ensuring that exceptions are thrown for invalid inputs.

Uploaded by

qoyhuda
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

#MobileConnecti

on
packagecom.servi
ce.
test
;

i
mpor
tjav
a.ut
il
.Ar
ray
List
;

i
mpor
tjav
a.ut
il
.Li
st;

i
mpor
tjav
a.ut
il
.Map;

i
mpor
tor
g.j
uni
t.
Bef
oreCl
ass;

i
mpor
tor
g.j
uni
t.
FixMet
hodOr
der
;

i
mpor
tor
g.j
uni
t.
runner
s.Met
hodSor
ter
s;

i
mpor
tor
g.j
uni
t.
Test
;

i
mpor
tst
ati
cor
g.j
uni
t.
Asser
t.
asser
tTr
ue;

i
mpor
tst
ati
cor
g.j
uni
t.
Asser
t.
asser
tFal
se;

i
mpor
tcom.
ser
vice.
except
ion.
Inv
ali
dMobi
l
eSer
viceExcept
ion;

i
mpor
tcom.
ser
vice.
model
.Mobi
l
e;

i
mpor
tcom.
ser
vice.
uti
l
.Mobi
l
eSer
vice;

@Fi
xMet
hodOr
der
(Met
hodSor
ter
s.NAME_
ASCENDI
NG)

publ
i
ccl
assMobi
l
eSer
viceTest{

pr
ivat
est
ati
cLi
st<Mobi
l
e>mobi
l
eLi
st=newAr
ray
List
<>(
);

pr
ivat
est
ati
cMobi
l
eSer
viceser
viceObj
;

@Bef
oreCl
ass
publ
i
cst
ati
cvoi
dset
Up(
)thr
owsExcept
ion{

ser
viceObj
=newMobi
l
eSer
vice(
);

mobi
l
eLi
st.
add(
new Mobi
l
e("
8712702058"
,"
Hansi
ka"
, "
Idea"
,
"
Prepai
d",
"xy
z")
);

/
/Cr
eat
efew obj
ect
sforMobi
l
ecl
assandaddt
omobi
l
eLi
st.

/
/Uset
hisl
i
stt
otestal
lthemet
hodsi
nMobi
l
eSer
vicecl
asst
hat
r
equi
resal
i
stofMobi
l
e

mobi
l
eLi
st.
add(
newMobi
l
e("
8712702058"
,"
Hansi
ka"
,"I
dea"
,"Pr
epai
d",
"xy
z")
);

mobi
l
eLi
st.
add(
new Mobi
l
e("
9090895819"
,"
Sar
any
a", "
Idea"
,
"
Post
pai
d",
"xy
z")
);

mobil
eLi
st.
add(
new
Mobi
l
e("
8712722234"
,"
Lakshmi
","
Air
tel
","
DTH"
,"xy
z")
);

mobi
l
eLi
st.
add(
new
Mobi
l
e("
8888002058"
,"
Rao"
,"I
dea"
,"mmm"
,"xy
z")
);

mobi
l
eLi
st.
add(
new
Mobi
l
e("
9867733465"
,"
Shawn"
,"Ai
rt
el"
,"Pr
epai
d",
"xy
z")
);

mobi
l
eLi
st.
add(
new
Mobi
l
e("
99999t
tt
tt
",
"Shawn"
,"Ai
rt
el"
,"Pr
epai
d",
"xy
z")
);

/
/Testt
hev
ali
dat
eConnect
ionTy
pemet
hodwhent
hev
aluei
spr
epai
d

@Test

publi
c voi
d t
est
11Val
i
dat
eConnect
ionTy
peWhenPr
epai
d() t
hrows
I
nval
i
dMobi
l
eServ
iceExcept
ion{

/
/fi
l
lcodeher
e

asser
tTr
ue(
ser
viceObj
.v
ali
dat
eConnect
ionTy
pe(
"Pr
epai
d")
);

}
/
/Testt
hev
ali
dat
eConnect
ionTy
pemet
hodwhent
hev
aluei
spost
pai
d

@Test

publi
c v oi
d t
est
12Val
i
dat
eConnect
ionTy
peWhenPost
pai
d() t
hrows
I
nval
i
dMobi
l
eServ
iceExcept
ion{

/
/fi
l
lcodeher
e

asser
tTr
ue(
ser
viceObj
.v
ali
dat
eConnect
ionTy
pe(
"Post
pai
d")
);

/
/Testt
hev
ali
dat
eConnect
ionTy
pemet
hodwhent
hev
aluei
sDTH

@Test

publi
c voi
d t
est
13Val
i
dat
eConnect
ionTy
peWhenDTH(
) t
hrows
I
nval
i
dMobi
l
eServ
iceExcept
ion{

/
/fi
l
lcodeher
e

asser
tTr
ue(
ser
viceObj
.v
ali
dat
eConnect
ionTy
pe(
"DTH"
));

/
/Testt
hev
ali
dat
eConnect
ionTy
pemet
hodwhent
hev
aluei
sinv
ali
d

@Test
(expect
ed=I
nval
i
dMobi
l
eSer
viceExcept
ion.
class)

publi
c voi
d t
est
14Val
i
dat
eConnect
ionTy
peWhenI
nval
i
d() t
hrows
I
nval
i
dMobi
l
eServ
iceExcept
ion{

/
/fi
l
lcodeher
e

asser
tTr
ue(
ser
viceObj
.v
ali
dat
eConnect
ionTy
pe(
"mmm"
));

/
/Testt
hev
iewMobi
l
eBy
Mobi
l
eNumbermet
hodwhent
hev
aluei
sval
i
d
@Test

publi
c v oi
d t
est
15Vi
ewMobi
l
eBy
Mobi
l
eNumber
WhenVal
i
d() t
hrows
I
nval
i
dMobi
l
eServ
iceExcept
ion{

/
/fi
l
lcodeher
e

ser
viceObj
.v
iewMobi
l
eBy
Mobi
l
eNumber
(mobi
l
eLi
st,
"8712702058"
);

You might also like