<file_sep>package com.lti.portal.microallotmovie.controller;

import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lti.portal.microallotmovie.document.Allotmovie;
import com.lti.portal.microallotmovie.dto.AllotmovieDetailDto;
import com.lti.portal.microallotmovie.dto.AllotmovieDto;
import com.lti.portal.microallotmovie.service.AllotmovieService;

@RestController
@RequestMapping("/api/allotmovie")
public class AllotmovieDetailController {
	private AllotmovieService allotmovieService;
	
	public AllotmovieDetailController(AllotmovieService allotmovieService) {
		// TODO Auto-generated constructor stub
		this.allotmovieService=allotmovieService;
	}
	
	//post method 
	@PostMapping("/save/{movieId}/{multiplexId}")
	public ResponseEntity<AllotmovieDetailDto> saveMovieMultiplexMapping(@PathVariable("movieId") String movieId,
			@PathVariable("multiplexId") String multiplexId, @RequestBody AllotmovieDto allotmovieDto)
	{
		AllotmovieDetailDto allotmovieDetailDto2 = this.allotmovieService.saveMovieMultiplexMapping(allotmovieDto,
				movieId,multiplexId);
		ResponseEntity<AllotmovieDetailDto> respose = new ResponseEntity<AllotmovieDetailDto>(allotmovieDetailDto2, HttpStatus.OK);
		return respose;
	}

	@GetMapping("/{multiplexId}/{screenno}")
	public ResponseEntity<Allotmovie> findByMultiplexIdAndScreenno (@PathVariable("multiplexId") String multiplexId,
			@PathVariable("screenno")int screenno)
	{
		
		Allotmovie allotmovie = this.allotmovieService.findByMultiplexIdAndScreenno(multiplexId, screenno);
		ResponseEntity<Allotmovie> response= new ResponseEntity<Allotmovie>(allotmovie, HttpStatus.OK);
		return response;
	}
	
	@GetMapping("/allotlist")
	public List<AllotmovieDetailDto> getAllAllotedList()
	{
		List<AllotmovieDetailDto> allotedList= this.allotmovieService.getAlldetails();
		return allotedList;
	}
	
	@GetMapping("/searchlist/{movieId}")
	public List<AllotmovieDetailDto> findByMovieId(@PathVariable("movieId") String movieId)
	{
		List<AllotmovieDetailDto> allotedsearchList= this.allotmovieService.findByMovieId(movieId);
		return allotedsearchList;
	}
	

}
<file_sep>package com.lti.training.microuser.dto;

import org.hibernate.validator.constraints.Length;

import lombok.Data;

@Data
public class LoginDto {
	private String loginId;
	@Length(min = 6)
	private String password;
}
<file_sep>export class allotMovie
{
    id:String;
    movieId:String;
    multiplexId:string;
    screenno:number;

}<file_sep>import { Component,OnInit } from '@angular/core';
import { AuthenticationService } from './service/authentication.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements  OnInit {
  title = 'multiplex';
  loggedin:boolean;
constructor(private authser:AuthenticationService){}
ngOnInit(): void {
  console.log("hi");
  this.loggedin=this.authser.isUserLoggedIn();
  console.log(this.loggedin);
}
}
<file_sep>import { Component, OnInit } from '@angular/core';
import{MovieService} from "../service/movie.service";
import{Movie} from "../movie/movie";
import{Router} from "@angular/router";



@Component({
  selector: 'app-list-movie',
  templateUrl: './list-movie.component.html',
  styleUrls: ['./list-movie.component.css']
})
export class ListMovieComponent implements OnInit {

  movies:Movie[];
  constructor(private movieService:MovieService,private router:Router) { }

  ngOnInit(): void {
    this.movieService.getMovies().subscribe(data=>{
      console.log("list");
      console.log(data);
      this.movies=data;
    });
  }

  deleteMovie(movie:Movie)
  {
    this.movieService.deleteMovie(movie.id).subscribe(data=>{
      console.log(data);
      if(data=="success")
      {
        this.router.navigate(['/listmovie']);
      }
      else{
        alert("OOPS!Something went wrong");
      }
    });
  }

  updateMovie(movie:Movie)
  {
    window.localStorage.removeItem("editmovieid")
    window.localStorage.setItem("editmovieid",movie.id.toString());
    this.router.navigate(['/updatemovie']);
  }

}
<file_sep>package com.lti.portal.micromovie.controller;

import java.util.List;

import org.apache.catalina.connector.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lti.portal.micromovie.document.MovieDetail;
import com.lti.portal.micromovie.dto.MovieDetailDto;
import com.lti.portal.micromovie.service.MovieService;

@RestController
@RequestMapping("/api/movie")
public class MovieDetailController {
	
    private MovieService movieService;
	
	@Autowired
	public MovieDetailController(MovieService movieService) {
		// TODO Auto-generated constructor stub
		this.movieService=movieService;
	}
	
	@PostMapping("/create")
	public ResponseEntity<MovieDetailDto> createMovie(@RequestBody MovieDetailDto movieDetailDto) {
		System.out.println("create movie");
		MovieDetailDto movieDetailDto2= this.movieService.createMovie(movieDetailDto);
		ResponseEntity<MovieDetailDto> response=new ResponseEntity<MovieDetailDto>(movieDetailDto2,HttpStatus.OK);
		return response;
	}
	//need to send both id and object
	@PutMapping("/{id}")
	public ResponseEntity<MovieDetailDto> updateMovie(@PathVariable(value="id")String movieId,@RequestBody MovieDetailDto movieDetailDto)
	{
		MovieDetailDto movieDetailDto2= this.movieService.updateMovie(movieId,movieDetailDto);
		ResponseEntity<MovieDetailDto> response= new ResponseEntity<MovieDetailDto>(movieDetailDto2,HttpStatus.OK);
		return response;
	}
	
	@DeleteMapping("/{id}")
	public String deleteMovie(@PathVariable(value="id")String movieId)
	{
		String deleteResponse= this.movieService.deleteMovie(movieId);
		return deleteResponse;
	}
	
	@GetMapping("/movies")
	public List<MovieDetail> getAllMovies()
	{
		List<MovieDetail> movieList= this.movieService.getAllMovies();
		return movieList;
	}
	
	@GetMapping("/{id}")
	public ResponseEntity<MovieDetailDto> getMovieById(@PathVariable(value="id")String movieId)
	{
		MovieDetailDto movieDetailDto2= this.movieService.getMovieById(movieId);
		ResponseEntity<MovieDetailDto> response= new ResponseEntity<MovieDetailDto>(movieDetailDto2,HttpStatus.OK);
		return response;
	}
	
	@GetMapping("/search/{name}")
	public List<MovieDetail> findByNameLike(@PathVariable(value="name") String name)
	{
		List<MovieDetail> movieList= this.movieService.findByNameLike(".*"+name+".*");
		System.out.println(movieList.size());
		return movieList;
	}

}
<file_sep>import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import{Movie} from '../movie/Movie';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import{AuthenticationService} from '../service/authentication.service';
import { debounceTime } from 'rxjs/internal/operators/debounceTime';


const VAIDATION_URL= "http://localhost:8765/micro-movie/api/movie";


@Injectable({
  providedIn: 'root'  
})
export class MovieService {



  constructor(private http:HttpClient,private auth:AuthenticationService) {}

    createMovie(movie: Movie):Observable<Movie>
     {
      let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
       
      return this.http.post(VAIDATION_URL+'/create', movie,{headers,responseType : "json"}).pipe(
        map(res=> res as Movie));
     }

     getMovies():Observable<any>
     {
       let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
        return this.http.get(VAIDATION_URL+'/movies',{headers,responseType : "json"}).pipe(
          map(res=> res ));
    }

    deleteMovie(id:String)
    {
      let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
        return this.http.delete(VAIDATION_URL +'/'+id,{headers,responseType : "text"}).pipe(
          map(res=> res ));
    }

    getMovieByID(id:String)
    {
      let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
        return this.http.get(VAIDATION_URL +'/'+id,{headers,responseType : "json"}).pipe(
          map(res=> res as Movie));
    }
    
    updateMovie(movie: Movie):Observable<Movie>
    {
     let authToken = sessionStorage.getItem("token");
     let headers = new HttpHeaders({
       Authorization : authToken,
       });
      
     return this.http.put(VAIDATION_URL+'/'+movie.id, movie,{headers,responseType : "json"}).pipe(
       map(res=> res as Movie));
    }
    
    getMovieByName(title:String):Observable<Movie[]>
    {

    let loginid="Visitor";
    let password="abc";
       let authToken = "Basic " + window.btoa(loginid + ":" + password);

      console.log(authToken);
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
        return this.http.get(VAIDATION_URL +'/search/'+title,{headers,responseType : "json"}).pipe(
          debounceTime(500), map(
           ( res:Movie[])=> {return (
              res.length != 0 ? res as Movie[] : [{"name": "No Record Found"} as any]
          );

           }
            
            ));
    }
    

   
}
<file_sep>export class Movie
{
    id:String;
    name:String;
    category:string;
    producer:string;
    director:string;

}<file_sep>import { Injectable } from '@angular/core';
import { allotMovie } from '../movie/allotMovie';
import { Observable } from 'rxjs';
import {map} from 'rxjs/operators';
import { HttpClient,HttpHeaders } from '@angular/common/http';

const VAIDATION_URL= "http://localhost:8765/micro-allotmovie/api/allotmovie";
@Injectable({
  providedIn: 'root'
})
export class AllotmovieService {

  constructor(private http:HttpClient) { }

  saveMovieMultiplexMapping(allotmovie:allotMovie):Observable<any>
  {
    let authToken = sessionStorage.getItem("token");
    let headers = new HttpHeaders({
      Authorization : authToken,
      });
     
    return this.http.post(VAIDATION_URL+'/save'+'/'+allotmovie.movieId+'/'+allotmovie.multiplexId, allotmovie,{headers,responseType : "json"}).pipe(
      map(res=> res as allotMovie));  }

      findByMultiplexIdAndScreenno(allotmovie:allotMovie)
{
  let authToken = sessionStorage.getItem("token");
    let headers = new HttpHeaders({
      Authorization : authToken,
      });
     
    return this.http.get(VAIDATION_URL+'/'+allotmovie.multiplexId+'/'+allotmovie.screenno,{headers,responseType : "json"}).pipe(
      map(res=> res as allotMovie)); 
}
getAllAllotedList():Observable<any>
{
  let authToken = sessionStorage.getItem("token");
    let headers = new HttpHeaders({
      Authorization : authToken,
      });
  return this.http.get(VAIDATION_URL+'/allotlist',{headers,responseType:"json"}).pipe(
    map(res=> res)
  );
}

findByMovieId(movieid:string):Observable<any>
{
  let loginid="Visitor";
  let password="abc";
     let authToken = "Basic " + window.btoa(loginid + ":" + password);
    let headers = new HttpHeaders({
      Authorization : authToken,
      });
  return this.http.get(VAIDATION_URL+'/searchlist/'+movieid,{headers,responseType:"json"}).pipe(
    map(res=> res)
  );
}
}


<file_sep>import { Component, OnInit } from '@angular/core';
import{AllotmovieService} from '../service/allotmovie.service';
import { allotMovieDetail } from '../movie/allotMovieDetail';

@Component({
  selector: 'app-list-allotmovie',
  templateUrl: './list-allotmovie.component.html',
  styleUrls: ['./list-allotmovie.component.css']
})
export class ListAllotmovieComponent implements OnInit {

  allotlist:allotMovieDetail[];

  constructor(private allotservice:AllotmovieService) { }

  ngOnInit(): void {
    this.allotservice.getAllAllotedList().subscribe(data=>{
      console.log("allt- list");
      console.log(data);
      this.allotlist=data;
      
    });
  }

}
<file_sep><div class="container-fluid">
    <div class="col-md-12">
    <h2 style="margin: auto"> Movie Details</h2>
       <table class="table table-striped">
      <thead>
      <tr>
        <th class="d-none d-sm-none">Id</th>
        <th>Movie name</th>
        <th>Movie Category</th>
        <th>Multiplex Name</th>
        <th>Multiplex Location</th>
        <th>Alloted Screen</th>

      </tr>
      </thead>
      <tbody>
      <tr *ngFor=" let allot of allotlist">
        <td class="d-none d-sm-none">{{allot.id}}</td>
        <td>{{allot.moviename.name}}</td>
         <td>{{allot.moviename.category}}</td>
        <td>{{allot.multiplexname.multiplexName}}</td>
        <td>{{allot.multiplexname.location}}</td>  
        <td>{{allot.screenno}}</td>
       </tr>
      </tbody>
    </table>
  </div>
  </div><file_sep>package com.lti.training.apigateway;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;

@Component
public class LoggingFilter extends ZuulFilter {

	private Logger log = LoggerFactory.getLogger(getClass());
	@Override
	public boolean shouldFilter() {
		// TODO Auto-generated method stub
		// true : this filter to be active
		// false : inactive
		return true;
	}

	@Override
	public Object run() throws ZuulException {
		// TODO Auto-generated method stub
		// what to do in case request is intercepted
		HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
		log.info("Zuul Intercepts : " + request.getRequestURL()) ;
		return null;
	}

	@Override
	public String filterType() {
		// TODO Auto-generated method stub
		return "pre";  // "post"
	}

	@Override
	public int filterOrder() {
		// TODO Auto-generated method stub
		// lower the value-higher the priority
		return 0;
	}

}
<file_sep>import{Multiplex} from '../multiplex/multiplex';
import{Movie} from '../movie/movie';
export class allotMovieDetail
{
    id:String;
    movieId:String;
    multiplexId:string;
    screenno:number;
    multiplexname:Multiplex;
    moviename: Movie;

}<file_sep>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CreateMovieComponent } from './create-movie/create-movie.component';
import { UpdateMovieComponent } from './update-movie/update-movie.component';
import { DeleteMovieComponent } from './delete-movie/delete-movie.component';
import { ListMovieComponent } from './list-movie/list-movie.component';

import { FormsModule,ReactiveFormsModule} from '@angular/forms';
import{MovieService} from "./service/movie.service";
import {HttpClientModule} from '@angular/common/http';
import { MenuComponent } from './menu/menu.component';
import{LoginComponent} from './login/login.component';
import { CreateMultiplexComponent } from './create-multiplex/create-multiplex.component';
import { ListMultiplexComponent } from './list-multiplex/list-multiplex.component';
import { DeleteMultiplexComponent } from './delete-multiplex/delete-multiplex.component';
import { UpdateMultiplexComponent } from './update-multiplex/update-multiplex.component';
import { AllotMovieComponent } from './allot-movie/allot-movie.component';
import { ListAllotmovieComponent } from './list-allotmovie/list-allotmovie.component';
import { LogoutComponent } from './logout/logout.component';
import { SearchComponent } from './search/search.component';
import {  MatInputModule } from '@angular/material/input';
import{MatAutocompleteModule} from '@angular/material/autocomplete';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';





@NgModule({
  declarations: [
    AppComponent,
    CreateMovieComponent,
    UpdateMovieComponent,
    DeleteMovieComponent,
    ListMovieComponent,
    MenuComponent,LoginComponent, CreateMultiplexComponent, ListMultiplexComponent, DeleteMultiplexComponent, UpdateMultiplexComponent, AllotMovieComponent, ListAllotmovieComponent, LogoutComponent, SearchComponent
  ], 
  imports: [
    BrowserModule,BrowserAnimationsModule,
    AppRoutingModule,FormsModule,ReactiveFormsModule,HttpClientModule,
    MatInputModule,MatAutocompleteModule
  ],
  providers: [MovieService],
  bootstrap: [AppComponent]
})
export class AppModule { }
<file_sep>package com.lti.training.microuser.dto;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class UserExceptionDto {

	private String message;
	private Integer errorCode;
	private Long timeStamp;
}
<file_sep>package com.lti.training.microuser.controller;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.lti.training.microuser.dto.RegisterDto;
import com.lti.training.microuser.dto.UserDetailDto;
import com.lti.training.microuser.service.UserService;

@RunWith(SpringRunner.class)
@WebMvcTest(UserController.class)// internally managed object
public class TestUserController {
	
	// MVC Test
	// MVC calls need to be mocked
	@Autowired
	private MockMvc mockMvc; // help to generate a mock mvc call
	
	@MockBean
	private UserService service;
	
	@Test
	public void testRegister() throws Exception {
		// mock the register method of userService
		RegisterDto registerDto = new RegisterDto("<EMAIL>", "1234567", "1234567", "First", "Last");
		UserDetailDto userDetailDto = new UserDetailDto("1","<EMAIL>",  "First", "Last");
		when(service.register(registerDto)).thenReturn(userDetailDto);
		
		// build a request to our controller
		RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/api/user/register")
										// JSON format is required to be passed 
										.content(asJsonString(registerDto))
										.contentType(MediaType.APPLICATION_JSON)
										.accept(MediaType.APPLICATION_JSON);
		// generate a request
		/*this.mockMvc.perform(requestBuilder)
		.andExpect(status().isOk())
		.andExpect(content().json(asJsonString(userDetailDto)))*/
	 	MvcResult result = this.mockMvc.perform(requestBuilder).andReturn();
		assertEquals(200, result.getResponse().getStatus());
		// assertEquals(asJsonString(userDetailDto), result.getResponse().getContentAsString());
	}
	
	
	// convert an object into JSON
	public static String asJsonString(Object obj) {
		ObjectMapper mapper = new ObjectMapper();
		String jsonString= "";
		try {
			jsonString = mapper.writeValueAsString(obj);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("Exception in JSON String conversion");
		}
		System.out.println("Json String : " + jsonString);
		return jsonString;
	}
	
}
<file_sep>package com.lti.portal.micromovie.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lti.portal.micromovie.dao.MovieDetailRepository;
import com.lti.portal.micromovie.document.MovieDetail;
import com.lti.portal.micromovie.dto.MovieDetailDto;

@Service
public class MovieServiceImpl implements MovieService {

	//convert dto to document and save
	private MovieDetailRepository movieDetailRepository;

	 public MovieServiceImpl(MovieDetailRepository movieDetailRepository) {
		// TODO Auto-generated constructor stub
		this.movieDetailRepository=movieDetailRepository;
	}
	@Override
	public MovieDetailDto createMovie(MovieDetailDto movieDetailDto) {
		// TODO Auto-generated method stub
		MovieDetail movieDetail = new MovieDetail(null, movieDetailDto.getName(), movieDetailDto.getCategory(),
									movieDetailDto.getProducer(), movieDetailDto.getDirector());
		movieDetail=this.movieDetailRepository.save(movieDetail);
		MovieDetailDto movieDetailDto1 = new MovieDetailDto(movieDetail.getId(), movieDetail.getName(),
				movieDetail.getCategory(), movieDetail.getProducer(), movieDetail.getDirector());
		return movieDetailDto;
	}
	
	@Override
	public MovieDetailDto updateMovie(String movieId,MovieDetailDto movieDetailDto) {
		// TODO Auto-generated method stub
		MovieDetail movieDetail = this.movieDetailRepository.findById(movieId).orElse(null);
		movieDetail.setName(movieDetailDto.getName());
		movieDetail.setCategory(movieDetailDto.getCategory());
		movieDetail.setDirector(movieDetailDto.getDirector());
		movieDetail.setProducer(movieDetailDto.getProducer());
		MovieDetail updMovieDetail = this.movieDetailRepository.save(movieDetail);
		MovieDetailDto movieDetailDto2= new MovieDetailDto(updMovieDetail.getId(), 
				updMovieDetail.getName(), updMovieDetail.getCategory(), updMovieDetail.getProducer(), updMovieDetail.getDirector());
		return movieDetailDto2;
	}
	@Override
	public String deleteMovie(String movieId) {
		// TODO Auto-generated method stub
		MovieDetail movieDetail =this.movieDetailRepository.findById(movieId).orElse(null);
		this.movieDetailRepository.delete(movieDetail);
				
		return "success";
	}
	@Override
	public List<MovieDetail> getAllMovies() {
		// TODO Auto-generated method stub
		
		List<MovieDetail> moviesList = this.movieDetailRepository.findAll();
		
		return moviesList;
	}
	@Override
	public MovieDetailDto getMovieById(String movieId) {
		// TODO Auto-generated method stub
		MovieDetail movieDetail =this.movieDetailRepository.findById(movieId).orElse(null);
		if(movieDetail!=null)
		{
		MovieDetailDto movieDetailDto2= new MovieDetailDto(movieDetail.getId(), 
				movieDetail.getName(), movieDetail.getCategory(), movieDetail.getProducer(), movieDetail.getDirector());
		
		return movieDetailDto2;
		}
		return null;
	}
	@Override
	public List<MovieDetail> findByNameLike(String name) {
		// TODO Auto-generated method stub
		List<MovieDetail> listbyname= this.movieDetailRepository.findByNameRegex(name);
		return listbyname;
	}

}
<file_sep>import { Component, OnInit } from '@angular/core';
import { AuthenticationService } from '../service/authentication.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {


  errorMessage : string;
  autherized : boolean
  constructor(public auth: AuthenticationService, public router: Router) { 
    this.errorMessage = "Invalid Credentials!!!";
    this.autherized = true;
  }

  login(txtLogin: HTMLInputElement, txtPass : HTMLInputElement){
      
    this.auth.authenticate(txtLogin.value, txtPass.value)
      .subscribe(
        // success Method
        (successData:string) => {
          console.log("LOGIN SUCCESS :" + successData);
          this.autherized = true; 
          this.router.navigate(['/listmovie']);
        },
        // failure
        failureData => {
          console.log("LOGIN FAILURE :" + failureData);
          this.autherized = false;
        }
      );

   /* if(this.auth.authenticate(txtLogin.value, txtPass.value)){
        this.autherized = true; 
        this.router.navigate(['/product']);
      }else{
          this.autherized = false;
      }*/ 
  }

  search()
  {
    console.log("hi");
    this.router.navigate(['/search']);
  }
  ngOnInit() {
  }

}
<file_sep>import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import{LoginComponent} from './login/login.component';
import{ListMovieComponent} from './list-movie/list-movie.component';
import{CreateMovieComponent} from './create-movie/create-movie.component';
import { UpdateMovieComponent } from './update-movie/update-movie.component';
import {ListMultiplexComponent} from './list-multiplex/list-multiplex.component';
import {CreateMultiplexComponent} from './create-multiplex/create-multiplex.component';
import{UpdateMultiplexComponent} from './update-multiplex/update-multiplex.component';
import{AllotMovieComponent} from './allot-movie/allot-movie.component';
import {ListAllotmovieComponent} from './list-allotmovie/list-allotmovie.component';
import{LogoutComponent} from './logout/logout.component';
import {SearchComponent} from './search/search.component';

const routes: Routes = [
  {path:"", redirectTo : "login", pathMatch : "full"},
   {path:"login", component : LoginComponent},
  {path:"listmovie",component:ListMovieComponent},
  {path:"createmovie",component:CreateMovieComponent},
  {path:"updatemovie",component:UpdateMovieComponent},
  {path:"listmultiplex",component:ListMultiplexComponent},
  {path:"createmultiplex",component:CreateMultiplexComponent},
  {path:"updatemultiplex",component:UpdateMultiplexComponent},
  {path:"allotmovie",component:AllotMovieComponent},
  {path:"listallotmovie",component:ListAllotmovieComponent},
  {path:"logout",component:LogoutComponent},
  {path:"search",component:SearchComponent}
  ];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
<file_sep>package com.lti.portal.micromovie.dao;

import java.util.List;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import com.lti.portal.micromovie.document.MovieDetail;

@Repository	
public interface MovieDetailRepository extends MongoRepository<MovieDetail, String> {
    @Query("{'name': {$regex: ?0 }})")
	List<MovieDetail> findByNameRegex(String name);

}
<file_sep>import { Component, OnInit } from '@angular/core';
import {FormControl,FormBuilder, FormGroup, Validators,ReactiveFormsModule} from "@angular/forms";
import {Router} from "@angular/router";
import{MovieService} from "../service/movie.service";


@Component({
  selector: 'app-create-movie',
  templateUrl: './create-movie.component.html',
  styleUrls: ['./create-movie.component.css']
})
export class CreateMovieComponent implements OnInit {

  constructor(private formBuilder:FormBuilder,private router:Router,private movieService:MovieService) { }

  createMovie:FormGroup;
  name:FormControl;
  category:FormControl;
  producer:FormControl;
  director:FormControl
  ngOnInit(): void {;
    
    this.createMovie=this.formBuilder.group({
      id:[],
      name:new FormControl("", Validators.required),
      category:new FormControl("", Validators.required),
      producer:new FormControl("", Validators.required),
      director:new FormControl("", Validators.required)
    });
  }
  onSubmit(){
    //alert("success");
   
    this.movieService.createMovie(this.createMovie.value)
    .subscribe(data=>{
console.log("succ");
console.log(data);
this.router.navigate(['/listmovie']);
    });
  
  }
}
<file_sep>import { Component, OnInit } from '@angular/core';
import{Router} from '@angular/router';
import {MovieService} from '../service/movie.service';
import {MultiplexService} from '../service/multiplex.service';
import{Movie} from '../movie/movie';
import{Multiplex} from '../multiplex/multiplex';
import{AllotmovieService} from '../service/allotmovie.service';
import {FormBuilder, FormGroup, Validators,ReactiveFormsModule} from "@angular/forms";


@Component({
  selector: 'app-allot-movie',
  templateUrl: './allot-movie.component.html',
  styleUrls: ['./allot-movie.component.css']
})
export class AllotMovieComponent implements OnInit {

  movies:Movie[];
  multiplexes:Multiplex[];
  screens:number[]=[];
  allotMovie:FormGroup;
  screeno:number;
  constructor(private router:Router,private movieService:MovieService,
    private multiplexService:MultiplexService,private formBuilder:FormBuilder,
    private allotmovieService:AllotmovieService) { }

  ngOnInit(): void {

    this.allotMovie=this.formBuilder.group({
      id:[],
      multiplexId:['',Validators.required],
      movieId:['',Validators.required],
      screenno:['',Validators.required]
    });

    this.movieService.getMovies().subscribe(data=>{
      this.movies=data;
    });

    this.multiplexService.getMultiplexes().subscribe(data=>{
        this.multiplexes=data;
        console.log("allotmovie");
        console.log(data);
        
    });
  }

  onSubmit()
  {
    this.allotmovieService.saveMovieMultiplexMapping(this.allotMovie.value).subscribe(data=>
      {
console.log(data);
alert("Mapped Successfully");
this.router.navigate(['/listallotmovie']);
      });
  }

  loadScreens(event:any)
  {
    this.screens=[];
    console.log("load screen");
    let value=event.target.value;
    console.log("value");
    console.log(value);
    this.multiplexService.getMultiplexByID(value).subscribe(data=>{
      //console.log(data);
      //console.log(JSON.parse(JSON.stringify(data)));
      //this.updateMovie.setValue=JSON.parse(JSON.stringify(data));
      this.screeno=data.noOfScreen;
      console.log(this.screeno);
      for (let i = 1; i <=this.screeno; i++) { 
        console.log ("Block statement execution no." + i);
       // this.screenno=this.multiplexes[i].noOfScreen;
        this.screens.push(i);

      }
    });
           
  }

  checkCombination(event:any)
  {
    // let screenno=event.target.value;
    // let multiplexId= this.allotMovie.value.multiplexId;
    // alert(multiplexId);

    this.allotmovieService.findByMultiplexIdAndScreenno(this.allotMovie.value).subscribe(data=>
      {
console.log(data);
if(data!=null)
{
alert("combination exist! please select different screen no");
this.router.navigate(['/listallotmovie']);
}
  });
  }
}
<file_sep>package com.lti.portal.microallotmovie.feignproxy;

import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import com.lti.portal.microallotmovie.dto.MovieDetailDto;


@FeignClient(name="micro-movie")
@RibbonClient(name="micro-movie")
public interface MicroMovieFeignProxy {
	@GetMapping("/api/movie/{id}")
	public ResponseEntity<MovieDetailDto> getMovieById(@PathVariable(value="id")String movieId);
	

}
<file_sep>import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators,ReactiveFormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import{MultiplexService} from '../service/multiplex.service';

@Component({
  selector: 'app-create-multiplex',
  templateUrl: './create-multiplex.component.html',
  styleUrls: ['./create-multiplex.component.css']
})
export class CreateMultiplexComponent implements OnInit {

  constructor(private formBuilder:FormBuilder,private router:Router,private multiplexService:MultiplexService) { }

  createMultiplex:FormGroup;

  ngOnInit(): void {
    this.createMultiplex=this.formBuilder.group({
      id:[],
      multiplexName:['',Validators.required],
      location:['',Validators.required],
      noOfScreen:['',Validators.required]
    });
  }
  onSubmit(){
    alert("success");

    this.multiplexService.createMultiplex(this.createMultiplex.value)
    .subscribe(data=>{
    console.log("succ");
    console.log(data);
    this.router.navigate(['/listmultiplex']);
    });
  }

}
<file_sep>package com.lti.training.microuser.controller.dao;

import java.util.List;

import com.lti.training.microuser.document.UserDetail;

public interface CustomRepository {

	List<UserDetail> complexLogic(String firstName, String emailId);
	
}
<file_sep>import { Injectable } from '@angular/core';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import { HttpClient,HttpHeaders } from '@angular/common/http';
import {Multiplex} from '../multiplex/multiplex';
const VAIDATION_URL= "http://localhost:8765/micro-multiplex/api/multiplex";

@Injectable({
  providedIn: 'root'
})
export class MultiplexService {

  constructor(private http:HttpClient) { }

  createMultiplex(multiplex: Multiplex):Observable<Multiplex>
     {
      let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
       
      return this.http.post(VAIDATION_URL+'/create', multiplex,{headers,responseType : "json"}).pipe(
        map(res=> res as Multiplex));
     }

     getMultiplexes():Observable<any>
     {
       let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
        return this.http.get(VAIDATION_URL+'/multiplexes',{headers,responseType : "json"}).pipe(
          map(res=> res ));
    }

    deleteMultiplex(id:String)
    {
      let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
        return this.http.delete(VAIDATION_URL +'/'+id,{headers,responseType : "text"}).pipe(
          map(res=> res ));
    }

    getMultiplexByID(id:String)
    {
      let authToken = sessionStorage.getItem("token");
      let headers = new HttpHeaders({
        Authorization : authToken,
        });
        return this.http.get(VAIDATION_URL +'/'+id,{headers,responseType : "json"}).pipe(
          map(res=> res as Multiplex));
    }
    
    updateMultipplex(multiplex: Multiplex):Observable<Multiplex>
    {
     let authToken = sessionStorage.getItem("token");
     let headers = new HttpHeaders({
       Authorization : authToken,
       });
      
     return this.http.put(VAIDATION_URL+'/'+multiplex.id, multiplex,{headers,responseType : "json"}).pipe(
       map(res=> res as Multiplex));
    }
    

}
<file_sep>import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import{MultiplexService} from '../service/multiplex.service';
import{Multiplex} from '../multiplex/multiplex';

@Component({
  selector: 'app-list-multiplex',
  templateUrl: './list-multiplex.component.html',
  styleUrls: ['./list-multiplex.component.css']
})
export class ListMultiplexComponent implements OnInit {

  multiplexes:Multiplex[];
  constructor(private router:Router,private multiplexService :MultiplexService) { }

  ngOnInit(): void {
    this.multiplexService.getMultiplexes().subscribe(data=>{
      console.log("list");
      console.log(data);
      this.multiplexes=data;
    });
  }

  deleteMultiplex(multiplex:Multiplex)
  {
    this.multiplexService.deleteMultiplex(multiplex.id).subscribe(data=>{
      console.log(data);
      if(data=="success")
      {
        this.router.navigate(['/listmultiplex']);
      }
      else{
        alert("OOPS!Something went wrong");
      }
    });
  }

  updateMultiplex(multiplex:Multiplex)
  {
    window.localStorage.removeItem("editmultiplexid")
    window.localStorage.setItem("editmultiplexid",multiplex.id.toString());
    this.router.navigate(['/updatemultiplex']);
  }


}
<file_sep>
<h4> Search for Movie details</h4>
<div class="col-md-6">

  <button class="btn btn-success"  (click) = "searchCall();"> click here after selecting movie below</button>
</div>
<!--   
<div ngIf="value == 'male'">Movie
    <input type="search" placeholder="Search Test here..."  #txt/>
    <input type="button" value="SEARCH" (click) = "searchCall(txt)"/> -->
    <div class="col-md-6 ">

     <form class="example-form">
        <mat-form-field  appearance="fill" class="example-full-width">
           <input type="text" matInput  placeholder="Search movies ..." [(ngModel)]="proxyValue" [formControl]="movieTitle" [matAutocomplete]="auto">  
            <mat-autocomplete #auto="matAutocomplete" (optionSelected)='selectedOption($event);'>
              <mat-option *ngFor="let movie of movies" [value]="movie">{{ movie.name }}
              </mat-option>
            </mat-autocomplete> 
          
        </mat-form-field>

    </form>
    </div>
    <div *ngIf="searchedin" >
      <div class="col-md-12">
      <h2 style="margin: auto"> Movie Details</h2>
         <table class="table table-striped">
        <thead> 
        <tr>
          <th class="d-none d-sm-none">Id</th>
          <th>Movie name</th>
          <th>Movie Category</th>
          <th>Multiplex Name</th>
          <th>Multiplex Location</th>
          <th>Alloted Screen</th>
  
        </tr>
        </thead>
        <tbody>
          
        <tr *ngFor=" let allot of allotlist">
          <td class="d-none d-sm-none">{{allot.id}}</td>
          <td>{{allot.moviename.name}}</td>
           <td>{{allot.moviename.category}}</td>
          <td>{{allot.multiplexname.multiplexName}}</td>
          <td>{{allot.multiplexname.location}}</td>  
          <td>{{allot.screenno}}</td>
         </tr>
        </tbody>
      </table>
    </div>
    </div>
    
  

    

<file_sep>package com.lti.training.microuser.dummy;


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import com.lti.training.microuser.controller.dao.DummyRepository;
import com.lti.training.microuser.service.DummyService;

// Mockito engine to run these test cases
@RunWith(MockitoJUnitRunner.class)
public class DummyMockTest {

	// instance of original service (create a real object)
	// inject the mock
	@InjectMocks
	DummyService service;
	
	// dependency on repository (any other resource)
	// create a mock object
	@Mock
	DummyRepository repository;
	
	@Test
	public void testCalculateSumFromDataService() {
		// setup is done
		// mock the implementation
		when(repository.getNumberList()).thenReturn(new int[] {1, 2, 3});
		
		int actual = this.service.calculateSumFromDataService();
		int expected = 6;
		assertEquals(expected, actual);
	}
	
	@Test
	public void testCalculateSumFromDataServiceEmpty() {
		// setup is done
		// mock the implementation
		when(repository.getNumberList()).thenReturn(new int[] {});
		
		int actual = this.service.calculateSumFromDataService();
		int expected = 0;
		assertEquals(expected, actual);
	}
}














<file_sep>import { Component, OnInit } from '@angular/core';
import { map, tap, debounceTime, distinctUntilChanged, switchMap, flatMap } from 'rxjs/operators';
import {Movie} from '../movie/movie';
import { Observable } from 'rxjs';
import { FormControl } from "@angular/forms";
import { MovieService } from '../service/movie.service';
import { Router } from '@angular/router';
import{AllotmovieService} from '../service/allotmovie.service';
import { allotMovieDetail } from '../movie/allotMovieDetail';

@Component({ 
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.css']
})
export class SearchComponent implements OnInit {

  movieTitle = new FormControl();
  movies: Movie[];
  allotlist:allotMovieDetail[];
  searchedin:boolean;
  show:boolean;
  id:any;

  constructor(private movieService:MovieService,private router:Router,private allotservice:AllotmovieService) { }

  ngOnInit(): void {
    //  this.movies = this.movieTitle.valueChanges.pipe( debounceTime( 400 ),
    //   distinctUntilChanged(),
    //   tap(() => this.moviesLoading = true ),
    // switchMap( title => this.movieService.getMovieByName( title ) ),
    // tap(() => this.moviesLoading = false ) );
    //  console.log(this.movies);

     this.movieTitle.valueChanges.subscribe( 
      term => {
        if (term != '') {
          this.movieService.getMovieByName(term).subscribe(
            data => {
              this.movies = data;
              //console.log(data);
              this.searchedin=false;
              //console.log(data[0].BookName);
          })
        }
    });
// console.log("init");
//       this.movieService.getMovieByName("Toy Story").subscribe(data=>{
//         console.log("inside");
// console.log(data);
       
  }

  searchCall()
  {
    let movieid= window.localStorage.getItem("selectedid");
    console.log("name"+movieid);
    this.allotservice.findByMovieId(movieid).subscribe(data=>{
      console.log(data);
      this.allotlist=data;
      if(this.allotlist.length>0)
      {
      this.searchedin=true;
     // this.show=false;
      }else{
        alert("No record Found");
        //this.show=true;
      }
      window.localStorage.removeItem("selectedid");
      
    });
    

  }
  proxyValue:any;
  selectedOption(event$)
  {
    this.proxyValue = event$.option.value.name;

    this.id = event$.option.value.id;

    let selectdid= window.localStorage.setItem("selectedid",this.id);
   // this.movieTitle.setValue=name;
  }
}
<file_sep>import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators,ReactiveFormsModule} from "@angular/forms";
import {Router} from "@angular/router";
import{MovieService} from "../service/movie.service";
import{Movie} from "../movie/movie";

@Component({
  selector: 'app-update-movie',
  templateUrl: './update-movie.component.html',
  styleUrls: ['./update-movie.component.css']
})
export class UpdateMovieComponent implements OnInit {

  movie:Movie;
  updateMovie:FormGroup;
  constructor(private movieserice:MovieService,private router:Router, private formBuilder:FormBuilder) { }

  ngOnInit(): void {

    let movieId= window.localStorage.getItem("editmovieid");

    this.updateMovie=this.formBuilder.group({
      id:[''],
      name:['',Validators.required],
      category:['',Validators.required],
      producer:['',Validators.required],
      director:['',Validators.required]
    });

    this.movieserice.getMovieByID(movieId).subscribe(data=>{
      console.log(data);
      console.log(JSON.parse(JSON.stringify(data)));
      //this.updateMovie.setValue=JSON.parse(JSON.stringify(data));
      this.updateMovie.setValue({
        name:data.name, category:data.category, producer:data.producer,director:data.director,id:data.id
      });
    });
  }

  onSubmit()
  {
    this.movieserice.updateMovie(this.updateMovie.value).subscribe(data=>{
     
        alert('Movie updated successfully.');
        this.router.navigate(['listmovie']);
      
    });
  }

}
<file_sep>import { Component, OnInit } from '@angular/core';
import { Multiplex } from '../multiplex/multiplex';
import { FormGroup, FormBuilder,Validators } from '@angular/forms';
import { Router } from '@angular/router';
import {MultiplexService} from '../service/multiplex.service';

@Component({
  selector: 'app-update-multiplex',
  templateUrl: './update-multiplex.component.html',
  styleUrls: ['./update-multiplex.component.css']
})
export class UpdateMultiplexComponent implements OnInit {

  multiplex:Multiplex;
  updateMultiplex:FormGroup;
  constructor(private multiplexService:MultiplexService,private router:Router,private formBuilder:FormBuilder) { }

  ngOnInit(): void {
    let multiplexid= window.localStorage.getItem("editmultiplexid");
    this.updateMultiplex= this.formBuilder.group({
      id:[''],
      multiplexName:['',Validators.required],
      location:['',Validators.required],
      noOfScreen:['',Validators.required]
    });
    this.multiplexService.getMultiplexByID(multiplexid).subscribe(data=>{
      console.log(data);
      console.log(JSON.parse(JSON.stringify(data)));
      //this.updateMovie.setValue=JSON.parse(JSON.stringify(data));
      this.updateMultiplex.setValue({
        multiplexName:data.multiplexName, location:data.location, noOfScreen:data.noOfScreen,id:data.id
      });
    });
  }

  onSubmit()
  {
    this.multiplexService.updateMultipplex(this.updateMultiplex.value).subscribe(data=>{
     
        alert('Movie updated successfully.');
        this.router.navigate(['listmovie']);
      
    });
  }

}
<file_sep>package com.lti.training.microuser.service;

import com.lti.training.microuser.dto.LoginDto;
import com.lti.training.microuser.dto.RegisterDto;
import com.lti.training.microuser.dto.UserDetailDto;

public interface UserService {
	public UserDetailDto register(RegisterDto registerDto);
	public UserDetailDto login(LoginDto loginDto);
	public boolean checkAlreadyInUse(String emailId);
	public UserDetailDto getUserDetail(String userId);
	
}
<file_sep>export class Multiplex
{
    id:String;
    multiplexName:String;
    location:string;
    noOfScreen:number;

}<file_sep>package com.lti.training.microuser.controller.dao;

public interface DummyRepository {
	int[] getNumberList();
}
<file_sep>import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-delete-multiplex',
  templateUrl: './delete-multiplex.component.html',
  styleUrls: ['./delete-multiplex.component.css']
})
export class DeleteMultiplexComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }

}
<file_sep>package com.lti.training.microuser.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class UserDetailDto {
	private String id;
	private String emailId;
	private String firstName;
	private String lastName;
}
<file_sep>import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders} from '@angular/common/http';
import {map} from 'rxjs/operators';
const VAIDATION_URL= "http://localhost:8765/micro-user/api/user/login";

@Injectable({
  providedIn: 'root'
})
export class AuthenticationService {

  constructor(private http:HttpClient) { }

  /*authenticate(loginid : string, password : string):boolean{
    // hard coded validation
    if(loginid === "First" && password === "abc"){
      // need to maintain status : session storage
      sessionStorage.setItem("user", loginid);
      return true;
    }else{
        return false;
    }
  }*/
  authenticate(loginid : string, password : string){
    // convert credentials into basic auth token
    let authToken = "Basic " + window.btoa(loginid + ":" + password);
    console.log(authToken);
    
    // header to sent with request
    let headers = new HttpHeaders({
      Authorization : authToken
      
    });

    return this.http.get(VAIDATION_URL, {headers,responseType : "text" }).pipe(
      // success
      map((successData:string) => {
        console.log("AUTH SUCCESS :" +  successData);
        sessionStorage.setItem("user", loginid);
        sessionStorage.setItem("token", authToken);
        return successData;
      }),
      // failure
      map((failureData:string) => {
        console.log("AUTH FAILED :" +  failureData);
        return failureData;
      })
    );

  }

  // method to return token
  getAuthenticationToken(){
    return sessionStorage.getItem("token");
  }


  isUserLoggedIn(): boolean{
    // if 'user' key is present
    let user = sessionStorage.getItem('user');
    if(user == null)
      return false;
    else
      return true;  
  }

  //  can have method to return type of user

  logout(){
    sessionStorage.removeItem('user');
    sessionStorage.removeItem('token');
  }


}
