CoordinatorAssignmentResource { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response upgrade(UpgradeVersions upgradeVersions, @Context UriInfo uriInfo, @HeaderParam(AIRSHIP_SLOTS_VERSION_HEADER) String expectedSlotsVersion, @HeaderParam(AIRSHIP_FORCE_HEADER) boolean force) { Preconditions.checkNotNull(upgradeVersions, "upgradeRepresentation must not be null"); List<UUID> uuids = Lists.transform(coordinator.getAllSlotStatus(), SlotStatus.uuidGetter()); Predicate<SlotStatus> slotFilter = SlotFilterBuilder.build(uriInfo, true, uuids); List<SlotStatus> results = coordinator.upgrade(slotFilter, upgradeVersions, expectedSlotsVersion, force); return Response.ok(transform(results, fromSlotStatus(coordinator.getAllSlotStatus(), repository))) .header(AIRSHIP_SLOTS_VERSION_HEADER, createSlotsVersion(results)) .build(); } @Inject  CoordinatorAssignmentResource(Coordinator coordinator, Repository repository); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response upgrade(UpgradeVersions upgradeVersions,
            @Context UriInfo uriInfo,
            @HeaderParam(AIRSHIP_SLOTS_VERSION_HEADER) String expectedSlotsVersion,
            @HeaderParam(AIRSHIP_FORCE_HEADER) boolean force);  }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".* single binary.*food.fruit:apple:1.0, food.fruit:banana:2.0-SNAPSHOT") public void testUpgradeDifferentBinaries() { UpgradeVersions upgradeVersions = new UpgradeVersions("2.0", "2.0"); UriInfo uriInfo = MockUriInfo.from("http: resource.upgrade(upgradeVersions, uriInfo, null, false); }
@Test public void testUpgradeDifferentBinaryVersion() { resource.upgrade(new UpgradeVersions("2.0", null), MockUriInfo.from("http: AgentStatus agentStatus = coordinator.getAgentByAgentId(agentId); SlotStatus apple1Status = agentStatus.getSlotStatus(apple1SlotId); SlotStatus apple2Status = agentStatus.getSlotStatus(apple2SlotId); SlotStatus bananaStatus = agentStatus.getSlotStatus(bananaSlotId); assertEquals(apple1Status.getAssignment().getBinary(), APPLE_ASSIGNMENT_2.getBinary()); assertEquals(apple2Status.getAssignment().getBinary(), APPLE_ASSIGNMENT.getBinary()); assertEquals(bananaStatus.getAssignment().getBinary(), BANANA_ASSIGNMENT.getBinary()); UpgradeVersions upgradeVersions = new UpgradeVersions("2.0", "2.0"); UriInfo uriInfo = MockUriInfo.from("http: Response response = resource.upgrade(upgradeVersions, uriInfo, null, false); coordinator.getAgentByAgentId(agentId); agentStatus = coordinator.getAgentByAgentId(agentId); apple1Status = agentStatus.getSlotStatus(apple1SlotId); apple2Status = agentStatus.getSlotStatus(apple2SlotId); bananaStatus = agentStatus.getSlotStatus(bananaSlotId); assertOkResponse(response, SlotLifecycleState.STOPPED, apple1Status, apple2Status); assertNull(response.getMetadata().get("Content-Type")); assertEquals(apple1Status.getState(), STOPPED); assertEquals(apple2Status.getState(), STOPPED); assertEquals(bananaStatus.getState(), STOPPED); assertEquals(apple1Status.getAssignment(), upgradeVersions.upgradeAssignment(MOCK_REPO, APPLE_ASSIGNMENT)); assertEquals(apple2Status.getAssignment(), upgradeVersions.upgradeAssignment(MOCK_REPO, APPLE_ASSIGNMENT)); assertEquals(bananaStatus.getAssignment(), BANANA_ASSIGNMENT); }